 
 class DeviceManager extends EventEmitter
   constructor: (@config) ->
-      @deviceProcesses = {}
-      @runningDevices = []
+    @deviceProcesses = {}
+    @runningDevices = []
 
   refreshDevices: (devices, callback) =>
     debug 'refreshDevices', _.pluck(devices, 'uuid')
 
-    @getDeviceOperations devices, @runningDevices, (devicesToStart, devicesToStop, devicesToRestart, unchangedDevices) =>
+    @getDevicesByOperation devices, (devicesToStart, devicesToStop, devicesToRestart, unchangedDevices) =>
       connectorsToInstall = _.uniq _.pluck devicesToStart, 'connector'
 
       async.series(
         [
-          (callback) => async.eachSeries connectorsToInstall, @installConnector, callback
+          (callback) => async.each connectorsToInstall, @installConnector, callback
           (callback) => async.each devicesToStop, @stopDevice, callback
-          (callback) => async.eachSeries devicesToStart, @setupDevice, callback
-          (callback) => async.eachSeries devicesToStart, @startDevice, callback
+          (callback) => async.each devicesToStart, @setupDevice, callback
+          (callback) => async.each devicesToStart, @startDevice, callback
           (callback) => async.each devicesToRestart, @restartDevice, callback
         ]
         (error, result)=>

      debug 'restartDevice error:', error if error?
      @startDevice device, callback

  stopDevice : (device, callback=->) =>
    debug 'stopDevice', device.uuid
    deviceProcess = @deviceProcesses[device.uuid]
    return callback null, device.uuid unless deviceProcess?

          callback error, result
      )

  getDevicesByOperation: (newDevices=[], callback=->) =>
    oldDevices = _.clone @runningDevices
    debug 'getDevicesByOperation'
    debug 'newDevices', _.pluck(newDevices, 'name')
    debug 'oldDevices', _.pluck(oldDevices, 'name')

    devicesToProcess = _.clone newDevices
    async.map devicesToProcess, @deviceExists, (error, remainingDevices) =>
      return callback error if error?

      remainingDevices = _.compact remainingDevices
      debug 'devices that exist', _.pluck(remainingDevices, 'name')

