anchor.diff:      end;
   
   
  -handle_event(enter, _OldState, {connected,_}=State, D) ->
  +handle_event(enter, OldState, {connected,_}=NewState, D) ->
       %% Entering the state where re-negotiation is possible
  -    init_renegotiate_timers(State, D);
  +    init_renegotiate_timers(OldState, NewState, D);
       
  -handle_event(enter, _OldState, {ext_info,_,renegotiate}=State, D) ->
  +handle_event(enter, OldState, {ext_info,_,renegotiate}=NewState, D) ->
       %% Could be hanging in exit_info state if nothing else arrives
  -    init_renegotiate_timers(State, D);
  -
  -handle_event(enter, {connected,_}, State, D) ->
  +    init_renegotiate_timers(OldState, NewState, D);
  +
  +handle_event(enter, {connected,_}=OldState, NewState, D) ->
       %% Exiting the state where re-negotiation is possible
  -    pause_renegotiate_timers(State, D);
  +    pause_renegotiate_timers(OldState, NewState, D);
   
   handle_event(cast, force_renegotiate, StateName, D) ->
       handle_event({timeout,renegotiate}, undefined, StateName, D);
  
positive.code:      io_lib:format("~p~n", [event_handler_result(Ret)])
      ];
  
  ssh_dbg_format(renegotiation, {call, {?MODULE,init_renegotiate_timers,[_State,D]}}) ->
      ["Renegotiation init\n",
       io_lib:format("rekey_limit: ~p ({ms,bytes})~ncheck_data_size: ~p (ms)~n", 
                     [?GET_OPT(rekey_limit, (D#data.ssh_params)#ssh.opts),
                      ?REKEY_DATA_TIMOUT])
      ];
  ssh_dbg_format(renegotiation, {return_from, {?MODULE,init_renegotiate_timers,2}, _Ret}) ->
      skip;
  
  ssh_dbg_format(renegotiation, {call, {?MODULE,pause_renegotiate_timers,[_State,_D]}}) ->
      ["Renegotiation pause\n"];
  ssh_dbg_format(renegotiation, {return_from, {?MODULE,pause_renegotiate_timers,2}, _Ret}) ->
      skip;
  
  ssh_dbg_format(renegotiation, {call, {?MODULE,start_rekeying,[_Role,_D]}}) ->
      ["Renegotiation start rekeying\n"];
  ssh_dbg_format(renegotiation, {return_from, {?MODULE,start_rekeying,2}, _Ret}) ->
      skip;
  
  ssh_dbg_format(renegotiation, {call, {?MODULE,check_data_rekeying_dbg,[SentSinceRekey, MaxSent]}}) ->
      ["Renegotiation check data sent\n",
       io_lib:format("TotalSentSinceRekey: ~p~nMaxBeforeRekey: ~p~nStartRekey: ~p~n",
                     [SentSinceRekey, MaxSent, SentSinceRekey >= MaxSent])
      ];
  ssh_dbg_format(renegotiation, {return_from, {?MODULE,check_data_rekeying_dbg,2}, _Ret}) ->
      skip;
  
  ssh_dbg_format(terminate, {call, {?MODULE,terminate, [Reason, StateName, D]}}) ->
      ExtraInfo =
  
negative.code:     {next_state, {kexinit,Role,renegotiate}, D}.
  
  
  init_renegotiate_timers(OldState, NewState, D) ->
      {RekeyTimeout,_MaxSent} = ?GET_OPT(rekey_limit, (D#data.ssh_params)#ssh.opts),
      {next_state, NewState, D, [{{timeout,renegotiate},     RekeyTimeout,       none},
                                 {{timeout,check_data_size}, ?REKEY_DATA_TIMOUT, none} ]}.
  
  
  pause_renegotiate_timers(_OldState, NewState, D) ->
      {next_state, NewState, D, [{{timeout,renegotiate},     infinity, none},
                                 {{timeout,check_data_size}, infinity, none} ]}.
  
  check_data_rekeying(Role, D) ->
      case inet:getstat(D#data.socket, [send_oct]) of
  