anchor.diff:      lists:foreach(fun(Stanza) ->
           Owner ! {stanza, transport(State), Stanza}
       end, Stanzas),
  +    case [StrEnd || #xmlstreamend{} = StrEnd <- Stanzas] of
  +        [] -> ok;
  +        _ -> gen_server:cast(self(), stop)
  +    end,
       Body.
   
   transport(#state{url = Url}) ->
  
positive.code:                compress = false,
                 rcv_pid = self()}.
  
  wrap_elem(#xmlstreamstart{attrs=Attrs}, #state{rid=Rid}) ->
      Version = proplists:get_value(<<"version">>, Attrs, <<"1.0">>),
      Lang = proplists:get_value(<<"xml:lang">>, Attrs, <<"en">>),
      To = proplists:get_value(<<"to">>, Attrs, <<"localhost">>),
      #xmlelement{name = <<"body">>, attrs=common_attrs(Rid) ++ [
              {<<"content">>, <<"text/xml; charset=utf-8">>},
              {<<"hold">>, <<"1">>},
              {<<"wait">>, <<"60">>},
              {<<"xml:lang">>, Lang},
              {<<"to">>, To}
              ]};
  wrap_elem(["</", <<"stream:stream">>, ">"], #state{sid=Sid, rid=Rid}) ->
      #xmlelement{name = <<"body">>, 
                  attrs = common_attrs(Rid, Sid) ++ [{<<"type">>, <<"terminate">>}],
  
negative.code:     StreamEnd = lxmppc_stanza:stream_end(),
      send0(transport(State), exml:to_iolist(StreamEnd), State),
      {stop, normal, ok, State}.
  handle_cast(stop, State) ->
      {stop, normal, State};
  handle_cast({send, Transport, Elem}, #state{rid=Rid} = State) when
          is_record(Elem, xmlstreamstart) ->
          InitBody = send0(Transport, Elem, State),
          NewState = State#state{rid=Rid+1,
  