             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

    putDirectory devicename, ".#{filePath}", false, (err, res) ->

        # Fetch only files with the same path/filename
        db.db.query { map: (doc) -> emit doc._id, doc if doc.docType is 'File' }, (err, res) ->
            for doc in res.rows
                doc = doc.value
                if doc.name is fileName and doc.path is filePath


fetchBinaries = (devicename, options, callback) ->
    # Fix callback
    if not callback? or typeof callback is 'object'
        callback = (err) ->
            process.exit 1 if err?
            process.exit 0

    # Get config
    remoteConfig = config.config.remotes[devicename]
