anchor.diff:  	       gen_server:cast(self(), Cast);
          true -> Links = gateway_util:now_decode(Message),
   	       case Links of
  -		 undefined -> ok;
  -		 _ ->  lists:foreach(fun(Link) -> 
  -                                         bind_refs(Link, State)
  -				     end, Links),
  -		       gen_server:cast(Protocol, {send, Payload})
  +           undefined -> ok;
  +           _ ->  lists:foreach(fun(Link) -> 
  +                   bind_refs(Link, State)
  +                 end, Links),
  +                 gen_server:cast(Protocol, {send, Payload})
   	       end
       end
     catch
  
positive.code:          terminate/2, code_change/3]).
  
  -record(state, {channel, protocol, subscriptions=[], exchanges=[], queues=[], sessionid, api_key}).
  
  -include_lib("amqp_client/include/amqp_client.hrl").
  -include_lib("gateway.hrl").
  
negative.code:   Channel = gen_server:call(gateway_gamqp, get_new_channel),
    {ok, #state{channel=Channel}}.
  
  
  handle_call({ready, Protocol, SessionId, ApiKey}, _From, State = #state{channel = Channel}) ->
    {ok, ClientExchange} = declare(client_exchange, SessionId, ApiKey, Channel),
    {ok, ClientQueue} = declare(client_queue, SessionId, ApiKey, Channel),
    Namespace = get_resource(namespace, <<"NAMED">>, ApiKey),
    bind(ClientExchange, Namespace, ApiKey, Channel),
    bind(ClientExchange, ClientQueue, ApiKey, Channel),
    amqp_channel:register_return_handler(Channel, self()),
  
    {ok, Tag} = consume_resource(ClientQueue, Channel),
  
    {reply, ok,
      State#state{
        protocol=Protocol,
        queues=[ClientQueue|State#state.queues],
        exchanges=[ClientExchange|State#state.exchanges],
        sessionid=SessionId,
        api_key = ApiKey
      }
  