 
 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)=>


    child = new (forever.Monitor)('command.js', foreverOptions)
    child.on 'stderr', (data) =>
      debug 'stderr', device.uuid, data.toString()
      @emit 'stderr', data.toString(), device

    child.on 'stdout', (data) =>
      debug 'stdout', device.uuid, data.toString()
      @emit 'stdout', data.toString(), device

    debug 'forever', {uuid: device.uuid, name: device.name}, 'starting'
    child.start()

    callback null, uuid

  stopDevices: (callback=->) =>
    async.each @runningDevices, @stopDevice, callback

module.exports = DeviceManager
