       do (endpoint) =>
         @[endpoint] = (args...) ->
           [data, callback] = @_parseArgs(args)
-          uuid = @_dispatch(endpoint, data)
+          uuid = @_generateUuid()
           @_registerCallback(uuid, callback) if callback?
-
+          @_dispatch(uuid, endpoint, data)
     @
 
   # Take an artibuarty number of arguments and determine which is the data and

  # using postMessage
  #
  # Returns a String of the Message's UUID
  _dispatch: (method, data) ->
    uuid = @_generateUuid()

    payload = @_payload(uuid, method, data)
    @_frame.postMessage payload, '*'
    uuid

  # Returns nothing
  ready: (callback) ->
    @_createFrame @serverUrl, =>
      uuid = @_generateUuid()
      @_dispatch(uuid, 'getEndpoints', true)

      @_registerCallback uuid, (methods) =>
        @_createEndpoints(methods)
