anchor.diff:  
       after Timeout ->
   	    {error, timeout}
  -    end.
  -
  +    end;
  +server_await_message(State, ExpectMessage, Timeout) 
  +  when is_map(State) ->
  +    receive
  +	{receive_message, {_, _, ExpectMessage}} ->
  +	    {ok, State};
  +
  +	Any ->
  +	    p("received unexpected event: ~p", [Any]),
  +	    {error, {unexpected_event, Any}}
  +
  +    after Timeout ->
  +	    {error, timeout}
  +    end.
  +
  +server_disconnect(#server{handle = Handle} = State) 
  +  when (Handle =/= undefined) ->
  +     megaco_tcp:close(Handle),
  +    {ok, State#server{handle = undefined}};
   server_disconnect(#server{handle = Handle} = State) 
     when (Handle =/= undefined) ->
        megaco_tcp:close(Handle),
       {ok, State#server{handle = undefined}}.
   
  -%% server_block(#server{handle = Handle} = State) 
  -%%   when (Handle =/= undefined) ->
  -%%      megaco_tcp:block(Handle),
  -%%     {ok, State}.
  -
  -%% server_unblock(#server{handle = Handle} = State) 
  -%%   when (Handle =/= undefined) ->
  -%%      megaco_tcp:unblock(Handle),
  -%%     {ok, State}.
  -
   server_stop_transport(#server{transport_ref = Ref} = State) 
     when (Ref =/= undefined) ->
       megaco_tcp:stop_transport(Ref),
  +    {ok, State};
  +server_stop_transport(#{transport_ref := Ref} = State) 
  +  when (Ref =/= undefined) ->
  +    megaco_tcp:stop_transport(Ref),
       {ok, State}.
   
   
  
positive.code: 
      after Timeout ->
  	    {error, timeout}
      end.
  
  client_block(#client{handle = Handle} = State) 
    when (Handle =/= undefined) ->
      megaco_tcp:block(Handle),
      {ok, State}.
  
  client_unblock(#client{handle = Handle} = State) 
    when (Handle =/= undefined) ->
      megaco_tcp:unblock(Handle),
      {ok, State}.
  
  client_disconnect(#client{handle = Handle} = State) 
    when (Handle =/= undefined) ->
      megaco_tcp:close(Handle),
      {ok, State#client{handle = undefined, control_pid = undefined}}.
  
  client_stop_transport(#client{transport_ref = Ref} = State) 
    when (Ref =/= undefined) ->
      megaco_tcp:stop_transport(Ref),
      {ok, State}.
  
      
  %% -------- Command handler ---------
  
  start_command_handler(Node, Commands, State, ShortName) ->
      Fun = fun() ->
  		  put(sname, ShortName), 
  		  process_flag(trap_exit, true),
  
negative.code: 	    {ok, State};
  	Error ->
  	    Error
      end;
  server_listen(#{transport_ref := Ref} = State, Options) 
    when is_list(Options) ->
      Opts = [{receive_handle, self()}, {module, ?MODULE} | Options], 
      case (catch megaco_tcp:listen(Ref, Opts)) of
  	ok ->
  	    {ok, State};
  	Error ->
  	    Error
      end.
  
  server_notify_listening(#server{parent = Parent} = State) 
    when is_record(State, server) ->
      Parent ! {listening, self()},
      {ok, State};
  server_notify_listening(#{parent := Parent} = State) ->
      Parent ! {listening, self()},
      {ok, State}.
  
  server_await_continue_signal(#server{parent = Parent} = State, Timeout) ->
      receive
  	{continue, Parent} ->
  	    {ok, State}
      after Timeout ->
  	    {error, timeout}
      end;
  server_await_continue_signal(#{parent := Parent} = State, Timeout) ->
      receive
  	{continue, Parent} ->
  	    {ok, State}
  