anchor.diff:      {Repls,D} = send_replies(Replies, D0),
       {stop_and_reply, normal, [{reply,From,ok}|Repls], D#data{connection_state=Connection}};
   
  -handle_event({call,_}, _, StateName, _) when StateName /= {connected,server},
  -					     StateName /= {connected,client}  ->
  +handle_event({call,_}, _, StateName, _) when not ?CONNECTED(StateName) ->
       {keep_state_and_data, [postpone]};
   
   handle_event({call,From}, {request, ChannelPid, ChannelId, Type, Data, Timeout}, StateName, D0) 
  -  when element(1,StateName) == connected ;
  -       element(1,StateName) == ext_info ->
  +  when ?CONNECTED(StateName) ->
       D = handle_request(ChannelPid, ChannelId, Type, Data, true, From, D0),
       %% Note reply to channel will happen later when reply is recived from peer on the socket
       start_channel_request_timer(ChannelId, From, Timeout),
       {keep_state, cache_request_idle_timer_check(D)};
   
   handle_event({call,From}, {request, ChannelId, Type, Data, Timeout}, StateName, D0) 
  -  when element(1,StateName) == connected ;
  -       element(1,StateName) == ext_info ->
  +  when ?CONNECTED(StateName) ->
       D = handle_request(ChannelId, Type, Data, true, From, D0),
       %% Note reply to channel will happen later when reply is recived from peer on the socket
       start_channel_request_timer(ChannelId, From, Timeout),
       {keep_state, cache_request_idle_timer_check(D)};
   
   handle_event({call,From}, {data, ChannelId, Type, Data, Timeout}, StateName, D0) 
  -  when element(1,StateName) == connected ;
  -       element(1,StateName) == ext_info ->
  +  when ?CONNECTED(StateName) ->
       {{replies, Replies}, Connection} =
   	ssh_connection:channel_data(ChannelId, Type, Data, D0#data.connection_state, From),
       {Repls,D} = send_replies(Replies, D0#data{connection_state = Connection}),
  
positive.code:     {keep_state_and_data, [{reply,From,Reply}]};
  
  handle_event({call,From}, {recv_window, ChannelId}, StateName, D) 
    when element(1,StateName) == connected ;
         element(1,StateName) == ext_info ->
      Reply = case ssh_channel:cache_lookup(cache(D), ChannelId) of
  		#channel{recv_window_size = WinSize,
  			 recv_packet_size = Packsize} ->
  
negative.code:     {keep_state, cache_cancel_idle_timer(D)};
  
  handle_event({call,From}, {send_window, ChannelId}, StateName, D) 
    when ?CONNECTED(StateName) ->
      Reply = case ssh_channel:cache_lookup(cache(D), ChannelId) of
  		#channel{send_window_size = WinSize,
  			 send_packet_size = Packsize} ->
  