anchor.diff:      NS = handle_data(XmlBody, S#state{requests = NewRequests}),
       NNS = case {detect_type(Attrs), NS#state.keepalive, NS#state.requests == []}
             of
  -              {streamend, _, _} -> NS;
  +              {streamend, _, _} -> close_requests(NS#state{terminated=true});
                 {_, false, _}     -> NS;
                 {_, true, true}   -> send(Transport, 
                                           empty_body(NS#state.rid, NS#state.sid),
  
positive.code: handle_call(get_requests, _From, State) ->
      {reply, length(State#state.requests), State};
  
  handle_call(stop, _From, #state{} = State) ->
      StreamEnd = escalus_stanza:stream_end(),
      {ok, _Reply, NewState} =
      sync_send0(transport(State), exml:to_iolist(StreamEnd), State),
      {stop, normal, ok, NewState}.
  
  
  handle_cast(stop, State) ->
      {stop, normal, State};
  
negative.code:     {reply, {ok, Keepalive, NewKeepalive},
       State#state{keepalive = NewKeepalive}};
  
  handle_call(mark_as_terminated, _From, #state{} = State) ->
      {reply, {ok, marked_as_terminated}, State#state{terminated=true}};
  
  handle_call(get_active, _From, #state{active = Active} = State) ->
      {reply, Active, State};
  handle_call({set_active, Active}, _From, State) ->
  