   deferred = Deferred()
   console.log "Dropping Database"
   mongodrop = run "mongo", ["coco", "--eval", "db.dropDatabase()"]
-  mongodrop.fail -> console.error "Error occurred"
-  mongodrop.always ->
+  mongodrop.fail -> console.error "Error occurred while dropping mongo. Make sure CoCo's MongoDB is running."
+  mongodrop.done ->
     console.log "Restoring from dump."
     mongorestore = run "mongorestore", [dbLocalPath]
-    mongorestore.always = deferred.resolve
+    mongorestore.always = deferred.resolve()
   deferred.promise()
 
 downloadDB = ->

  if useNext
    mongopath = path
    break
  useNext = path == '--mongopath'
mongopath += '/bin/' if mongopath.length
mongopath += 'mongodb' # mongodb is in path.


  installUpdates()

if '--resetdb' in process.argv
  if '--dldb' in process.argv
    downloadDB().done ->
        resetDB().done ->
          cleanUpTmp() if '--cleanup' in process.argv
  else
    resetDB().done ->
      cleanUpTmp() if '--cleanup' in process.argv
else if '--dldb' in process.argv
  downloadDB()

# TODO: Could advice to start SCOCODE.bat et al. here

