         callback null, media
 
 mimeItemMap =
-    audio: 'audioItem.musicTrack'
-    image: 'imageItem'
+    audio: 'object.item.audioItem.musicTrack'
+    image: 'object.item.imageItem'
+    text: 'object.item.textItem'
 
 makeItem = (type, file, callback) ->
     media =
-        type: 'item'
-        instance: mimeItemMap[type]
+        class: mimeItemMap[type] or 'object.item'
         location: file
      switch type
         when 'audio'
-            stream = fs.createReadStream file
-            parser = new mmd stream
+            parser = new mmd stream = fs.createReadStream file
             parser.on 'metadata', (data) ->
-                media.creator = data.artist or 'Unknown'
+                media.creator = data.artist?[0] or 'Unknown'
                 media.title = data.title or 'Untitled'
                 media.album = data.album or 'Untitled'
                 callback null, media

        (err) -> callback err, sortedFiles

mimeContainerMap =
    audio: 'album.musicAlbum'

makeContainer = (dir, sortedFiles, callback) ->
    contentType = getContainerType sortedFiles
    media =
        type: 'container'
        instance: mimeContainerMap[contentType]
        location: dir
    
    if contentType is 'audio'
        stream = fs.createReadStream sortedFiles[contentType][0]
        parser = new mmd stream
        parser.on 'metadata', (data) ->
            media.creator = data.albumartist[0]
            media.title = data.album
            callback null, media
        parser.on 'done', (err) ->

mmd = require 'musicmetadata'
path = require 'path'
upnp = require 'upnp-device'
mime.define 'audio/flac': ['flac']

getContainerType = (fileTypes) ->
    maxVal = 0
