anchor.diff:                                        host, bson:utf8(Host),
                                         resource, bson:utf8(Resource),
                                         connected, true}),
  -    NewDoc = doc_close_connection(mongo:next(Cursor), JID, IPAddress),
  +    case doc_close_connection(mongo:next(Cursor), JID, null) of
  +      {ok, NewDoc} -> mongo:save(connections, NewDoc);
  +      {failure, Reason} ->
  +        ?DEBUG("Failed to mark connection as closed: ~p", [Reason]),
  +        failure
  +    end,
       mongo:close_cursor(Cursor),
  -    mongo:save(connections, NewDoc)
     end);
   handle_cast(_Msg, State) ->
     {noreply, State}.
  
positive.code:   handle_presence(disconnect, {User, Server, Resource}, null).
  
  %@doc Handles presence stanzas sent by users
  handle_presence(UserState, JID, IPAddress) ->
    % Processes the stanza in the gen_server
    gen_server:cast(?MODULE, {UserState, JID, IPAddress}),
    report_event(Server, atom_to_list(UserState)),
  
negative.code:   end.
  
  %@doc Returns geosplatial information for given IP
  lookup_ip(null) -> [{latitude, 0.0}, {longitude, 0.0}];
  lookup_ip(IPAddress) ->
    ?DEBUG("Decoding IP address ~p", [IPAddress]),
    [_|Data] = erlang:tuple_to_list(element(2, egeoip:lookup(IPAddress))),
  