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

            , callback


putDirectory = (devicename, directoryPath, recursive, callback) ->
    # Fix callback
    if not callback? or typeof callback is 'object'
        callback = (err) ->

process = require 'process'
uuid = require 'node-uuid'
async = require 'async'
chokidar = require 'chokidar'
urlParser = require 'url'
log = require('printit')
    prefix: 'Data Proxy'

