     connectorManager = new ConnectorManager @config.tmpPath, connector
     connectorManager.install (error) =>
       if error?
-        debug 'install error', 'doing rimraf on', @config.tmpPath, '/node_modules/', connector
-        rimraf @config.tmpPath + '/node_modules/' + connector, (error) =>
-          debug 'unable to delete tmpPath!', error
+        connectorPath = @getConnectorPath device
+        debug 'install error', 'doing rimraf on', connectorPath
+        rimraf connectorPath, (error) =>
+          debug 'unable to delete tmpPath!', error if error
         return callback error
       debug 'connector installed', connector
       @connectorsInstalled[connector] = true

  setupDevice: (device, _callback) =>
    callback = @generateLogCallback _callback, 'setup-device', device
    return callback new Error('Invalid connector') if _.isEmpty device.connector

    devicePath = @getDevicePath device
    connectorPath = path.join @config.tmpPath, 'node_modules', device.connector

    debug 'path', devicePath
    debug 'connectorPath', connectorPath
    debug 'copying files', devicePath

    rimraf devicePath, (error) =>
      return callback error if error?

      fs.copy connectorPath, devicePath, (error) =>
        return callback error if error?

        debug 'done copying', devicePath
        callback()

  writeMeshbluJSON: (devicePath, device, _callback=->) =>
    callback = @generateLogCallback _callback, 'write-meshblu-json', device

    meshbluFilename = path.join devicePath, 'meshblu.json'
    deviceConfig = _.extend {},
      device,
      server: @config.server, port: @config.port

    deviceConfig = _.pick deviceConfig, 'uuid', 'token', 'server', 'port'
    meshbluConfig = JSON.stringify deviceConfig, null, 2
    debug 'writing meshblu.json', devicePath
    fs.writeFile meshbluFilename, meshbluConfig, callback

  shutdown: (_callback=->) =>
    callback = @generateLogCallback _callback, 'shutdown'

_ = require 'lodash'
url = require 'url'
path = require 'path'
util = require 'util'
Uuid = require 'node-uuid'
async = require 'async'
debug = require('debug')('gateblu-forever:device-manager')
rimraf = require 'rimraf'
{exec} = require 'child_process'
forever = require 'forever-monitor'
packageJSON = require './package.json'
MeshbluHttp = require 'meshblu-http'
{EventEmitter2} = require 'eventemitter2'
ConnectorManager = require './connector-manager'

class DeviceManager extends EventEmitter2
  constructor: (@config, dependencies={}) ->
