         # replace the handler. when called it will remove the handler.
         @proto.localStore.items[id] = ()=>
           delete @proto.localStore.items[id]
-          response = arguments[0].withArgs[0]
+          response = arguments[0]
           fn.apply null, [response.error, response.result]
 
   onOpen: ->

    if @autoReconnect
      KD.utils.defer => @setBackoffTimeout @bound "connect"

  onMessage: (evt)->
    data = evt.data
    log "onMessage", data
    req = JSON.parse data
    @proto.handle(req)

  onError: (evt)->
    log "#{@kite.name} error: #{evt.data}"

# It is analogous to RemoteKite class in go/koding/newkite/kite/remote.go file.
class NewKite extends KDObject

  {setAt} = Bongo.JsPath
  [NOTREADY, READY, CLOSED] = [0,1,3]

  constructor: (kite, authentication, options={})->
