anchor.diff:              Data = none,
               throw(tcp_error)
       end,
  -    lager:debug("Read ~B bytes from socket", [size(hd(Data))]),
  +    lager:debug("~B bytes received from ~s", [size(hd(Data)), State#state.peer]),
       Data;
   read_buffer(State, _) ->
       State#state.buf.
  
positive.code:         end
      catch
          throw:tcp_closed ->
              lager:info("Connection closed by ~B.~B.~B.~B:~B",
                         [O1, O2, O3, O4, P]);
          throw:tcp_error ->
              lager:info("Connection error with ~B.~B.~B.~B:~B",
                         [O1, O2, O3, O4, P])
      end.
  
  log_frame({frame, Cmd, Headers, Body}, Peer) ->
      {{O1, O2, O3, O4}, P} = Peer,
      lager:debug("Frame received from ~B.~B.~B.~B:~B:~n"
                  "\tCmd = ~s~n\tHeaders = ~p~n\tBody = ~p",
                  [O1, O2, O3, O4, P, Cmd, Headers, Body]).
  
  read_frame(State) ->
      try
  
negative.code: %%%-----------------------------------------------------------------------------
  
  handle_connection(Socket, none) ->
      {ok, Peer0} = gen_tcpd:peername(Socket),
      Peer = format_peer(Peer0),
      lager:info("New connection from ~s", [Peer]),
      {ok, [{recbuf, RecvLen}]} = gen_tcpd:getopts(Socket, [recbuf]),
      handle_connection(Socket, #state{sock = Socket, peer = Peer, recv_len = RecvLen});
  handle_connection(Socket, State) ->
      try
          gen_tcpd:send(Socket, "HELO\n"),
          case read_frame(State) of
              {error, _} ->
                  lager:info("Invalid frame received from ~s", [State#state.peer]),
                  gen_tcpd:close(Socket);
              {Frame, State2} ->
                  log_frame(Frame, State2#state.peer),
  