anchor.diff:      [handle_data(AutoResponse, Sock, M) || M <- Messages],
       ok = inet:setopts(Sock, [{active,once}]),
       {noreply, State#state{buffer = Incomplete}};
  -handle_info({tcp_closed, Sock}, State = #state{sock = Sock}) ->
  -    ?SYS_WARN("Socket ~p closed.", [Sock]),
  +handle_info({tcp_closed, Sock}, State = #state{name = Name, sock = Sock}) ->
  +    ?SYS_WARN("Connection for ~p closed.", [Name]),
       {stop, normal, State};
   handle_info({tcp_closed, Socket}, State) ->
       ?SYS_WARN("Unknown socket ~p closed.", [Socket]),
       {stop, normal, State};
  -handle_info({'EXIT', _, Reason}, State) ->
  -    {stop, Reason, State};
  +handle_info({'EXIT', Pid, Reason}, State = #state{name = Name, sock = undefined}) ->
  +    ?SYS_INFO("~p > ~p died, reason ~p",
  +              [Name, element(2, process_info(Pid, registered_name)), Reason]),
  +    {noreply, State};
  +handle_info({'EXIT', Pid, Reason}, State = #state{lsock = undefined}) ->
  +    {stop, {Pid, Reason}, State};
   handle_info(check_send_deliver_sm, State) ->
       case ets:first(get(name)) of
           '$end_of_table' ->
  
positive.code: 
  handle_cast(accept, State = #state{lsock = LSock}) ->
      {ok, {Ip, Port}} = inet:sockname(LSock),
      ?SYS_INFO("Accepting on  ~s:~p", [inet:ntoa(Ip), Port]),
      {ok, Sock} = gen_tcp:accept(LSock),
      {ok, {RIp, RPort}} = inet:peername(Sock),
      {ok, {LIp, LPort}} = inet:sockname(Sock),
      {ok,  Pid} =
      gen_server:start_link(
        {local, list_to_atom(
                  lists:concat(
                    [inet:ntoa(RIp), ":", RPort, "-",
                     inet:ntoa(LIp), ":", LPort]))},
        ?MODULE, [Sock], []),
      ok = gen_tcp:controlling_process(Sock, Pid),
      ok = gen_server:cast(Pid, arm),
      ok = gen_server:cast(self(), accept),
  
negative.code:     ?SYS_INFO("Unhandled message: ~p", [Any]),
      {noreply, State}.
  
  terminate(Reason, #state{name = Name, lsock = undefined}) ->
      ?SYS_INFO("client ~p down ~p", [Name, Reason]);
  terminate(Reason, #state{name = Name, sock = undefined}) ->
      ?SYS_INFO("server ~p down ~p", [Name, Reason]).
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  