     WORK_STATUS: [ "string", "number", "number" ]
 
   connect: ->
+    if @connected and not @processing
+      @processCommandQueue()
     if @connected or @connecting
-      @processCommandQueue()  if @connected and not @processing
       return false
     @connecting = true
-    console.log "connecting..."  if @debug
-    @socket = (netlib.connect or netlib.createConnection)(@port, @host)
+
+    console.log "connecting..." if @debug
+
+    @socket = (netlib.connect or netlib.createConnection) @port, @host
+    
     @socket.on "connect", (->
       @socket.setKeepAlive true
       @connecting = false
       @connected = true
-      console.log "connected!"  if @debug
+
+      console.log "connected!" if @debug
+
       @emit "connect"
       @processCommandQueue()
-    ).bind(this)
-    @socket.on "end", @close.bind(this)
-    @socket.on "close", @close.bind(this)
-    @socket.on "error", @errorHandler.bind(this)
-    @socket.on "data", @receive.bind(this)
+    ).bind(@)
+
+    @socket.on "end", @close.bind @
+    @socket.on "close", @close.bind @
+    @socket.on "error", @errorHandler.bind @
+    @socket.on "data", @receive.bind @
 
   close: ->
     if @connected


  receive_JOB_ASSIGN: (handle, name, payload) ->
    if typeof @workers[name] is "function"
      worker = new Worker(this, handle, name, payload)
      @currentWorkers[handle] = worker
      @workers[name] payload, worker


    len = args.length

    while i < len
      args[i] = new Buffer (args[i] or "").toString(), "utf-8" unless args[i] instanceof Buffer
      bodyLength += args[i].length
      i++
    bodyLength += if args.length > 1 then args.length - 1 else 0
    body = new Buffer bodyLength + 12
    body.writeUInt32BE 0x00524551, 0
    body.writeUInt32BE commandId, 4
    body.writeUInt32BE bodyLength, 8
