 
         data = login: options.deviceName
 
-        getCredentials = (res) ->
-            if res[0].body.error
-                callback res[0].body.error
+        getCredentials = (res, body) ->
+            if body.error?
+                throw new Error(body.error)
             else
-                body = res[0].body
-                callback null,
-                    id: body.id
-                    password: body.password
-
-        onError =  (err) ->
-            log.error err.toString()
-            console.error err
-            callback err
+                id: body.id
+                password: body.password
 
         client.postAsync('device/', data)
-            .then getCredentials
-            .catch onError
+            .spread getCredentials
+            .nodeify callback
 
 
     # Unregister device remotely, ask for revocation.

            # Lock file watcher to avoid remotely downloaded files to be re-uploaded
            filesystem.watchingLocked = true

            unlockFileSystemAndReturn =  ->
                filesystem.watchingLocked = false
                callback null


            log.info "Running synchronization with remote database"
            replicate = pouch.db.sync

        return replicate


    runReplication: (fromRemote, toRemote, continuous,
