             path: dirPath
             tags: []
 
-        db.db.put document, newId, (err, res) ->
+        db.put document, newId, (err, res) ->
             if recursive
-                return putSubFiles callback
+                putSubFiles callback
             else
-                return callback err, res
+                callback err, res
 
     putSubFiles = (callback) ->
         # List files in directory

    dirLastModification = stats.mtime

    # Lookup for existing directory
    db.db.query { map: (doc) -> emit doc._id, doc if doc.docType is 'Folder' }, (err, res) ->
        for doc in res.rows
            doc = doc.value
            if doc.path is dirPath and doc.name is dirName

                fileName = "#{absolutePath}/#{file}"
                # Upload file if it is a file
                if fs.lstatSync(fileName).isFile()
                    putFile devicename, fileName, callback
                # Upload directory recursively if it is a directory
                else if fs.lstatSync(fileName).isDirectory()
                    putDirectory devicename, fileName, recursive, callback
            if res.length is 0
                log.info "No file to upload in: #{relativePath}"
                callback err, res
