anchor.diff:  
     ok.
   
  -on_set_presence(User, Server, Resource, _Packet) ->
  -  {IPAddress, _} = ejabberd_sm:get_user_ip(User, Server, Resource),
  -  handle_presence(connect, {User, Server, Resource}, IPAddress).
  -on_unset_presence(User, Server, Resource, _Status) ->
  -  handle_presence(disconnect, {User, Server, Resource}, null).
  +on_set_presence(User, Host, Resource, _Packet) ->
  +  {IPAddress, _} = ejabberd_sm:get_user_ip(User, Host, Resource),
  +  handle_presence(connect, {User, Host, Resource}, IPAddress).
  +on_unset_presence(User, Host, Resource, _Status) ->
  +  handle_presence(disconnect, {User, Host, Resource}, null).
   
   %@doc Handles presence stanzas sent by users
  -handle_presence(UserState, {_User, Server, _Resource} = JID, IPAddress) ->
  +handle_presence(UserState, {_User, Host, _Resource} = JID, IPAddress) ->
     % Processes the stanza in the gen_server
     gen_server:cast(?MODULE, {UserState, JID, IPAddress}),
  -  report_event(Server, atom_to_list(UserState)),
  +  report_event(Host, atom_to_list(UserState)),
     ok.
   
   %%% gen_server %%%
  
positive.code: parse_component_jid(User) ->
    case string:tokens(User, "_") of
      ["agent"|_] = Props -> lists:zip([component, version, cores, jobs, uuid, ukn], lists:map(fun bson:utf8/1, Props));
      [Component|_] -> [{component, Component}]
    end.
  
  %@doc Creates a MonoDB document describing the connection
  
negative.code: doc_close_connection({}, _) -> {failure, nodoc};
  doc_close_connection({Doc}, {User, _Host, _Resource}) ->
    % Converts a list of tuples ([{x, Val}]) into a list of lists ([[x, Val]]) and flattens it ([x, Val]) for BSON
    AgentData = erlang:list_to_tuple(lists:flatmap(fun erlang:tuple_to_list/1, parse_component_jid(User))),
    NewData = {connected, false,
               disconnected_at, bson:timenow(),
               agent_data, AgentData},
  