anchor.diff:    GeoData = lookup_ip(IPAddress),
     Lng = proplists:get_value(longitude, GeoData),
     Lat = proplists:get_value(latitude, GeoData),
  +  % 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))),
   
     {user,         bson:utf8(User),
      host,         bson:utf8(Host),
      resource,     bson:utf8(Resource),
      loc,          [Lng, Lat],
  +   agent_data,   AgentData,
      connected_at, bson:timenow(),
      connected,    true}.
   
   %@doc Marks connection as closed and appends data extracted from agent's JID
  -doc_close_connection({}, _) -> {failure, nosession};
  -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))),
  +doc_close_connection({}) -> {failure, nosession};
  +doc_close_connection({Doc}) ->
     NewData = {connected, false,
  -             disconnected_at, bson:timenow(),
  -             agent_data, AgentData},
  +             disconnected_at, bson:timenow()},
     NewDoc = bson:merge(NewData, Doc),
     {ok, NewDoc}.
   
  
positive.code: %@doc Parses JID (username part) of an agent (ex.: agent_s-10829_1_7_18225d4f-e3f7-4c18-9a18-d6c06992d272_-g)
  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, bson:utf8(Component)}]
    end.
  
  
negative.code:                                       host, bson:utf8(Host),
                                        resource, bson:utf8(Resource),
                                        connected, true}),
      case doc_close_connection(mongo:next(Cursor)) of
        {ok, NewDoc} -> mongo:save(connections, NewDoc);
        {failure, Reason} ->
          ?DEBUG("Failed to mark connection from ~p as closed: ~p", [JID, Reason]),
  