anchor.diff:  
     ejabberd_hooks:delete(set_presence_hook, Host, ?MODULE, on_presence),
   
  -  application:stop(mongodb),
  -  application:stop(),
  +  Proc = gen_mod:get_module_proc(Host, ?MODULE),
  +  supervisor:terminate_child(ejabberd_sup, Proc),
  +  supervisor:delete_child(ejabberd_sup, Proc),
   
     ok.
   
  -on_presence(User, Server, Resource, _Packet) ->
  +on_presence(User, Server, Resource, {xmlelement, "presence", _ , _} = Packet) ->
     {IPAddress, _} = ejabberd_sm:get_user_ip(User, Server, Resource),
  -  Data = lookup_ip(IPAddress),
  -  ?DEBUG("User with the IP address ~p sent a presence from (~p, ~p)", [IPAddress,
  -                                                                       lists:keyfind(latitude, 1, Data),
  -                                                                       lists:keyfind(longitude, 1, Data)]),
  +  ?INFO_MSG("***Connected user ~p from ~p", [User, IPAddress]),
  +  gen_server:cast(?MODULE, {userconnect, User, IPAddress}),
     report_event(Server, "connect"),
     ok.
  +
  +%%% gen_server %%%
  +start_link(_Host, Opts) ->
  +  gen_server:start_link({local, ?MODULE}, ?MODULE, Opts, []).
  +
  +init(Args) ->
  +  application:start(mongodb),
  +  application:start(egeoip),
  +
  +  ?DEBUG("mod_copilot_server:init ~p", [Args]),
  +  %Host = {lists:keyfind(mongodb_host, 1, Args), lists:keyfind(mongodb_port, 1, Data)},
  +  %{ok, Conn} = mongo:connect(Host),
  +
  +  State = [{ok, ok}, {mod_opts, Args}],
  +  {ok, State}.
  +
  +handle_call(_Request, _From, State) ->
  +  Reply = ok,
  +  {reply, Reply, State}.
  +
  +handle_cast({userconnect, JID, IPAddress}, State) ->
  +  GeoData = lookup_ip(IPAddress),
  +  {noreply, State}.
  +
  +handle_cast(_Msg, State) ->
  +  {noreply, State}.
  +
  +handle_info(_Info, State) ->
  +  {noreply, State}.
  +
  +terminate(_Reason, _State) ->
  +  application:stop(mongodb),
  +  application:stop(egeoip),
  +  ok.
  +
  +code_change(_OldVsn, State, _Extra) ->
  + {ok, State}.
   
   %%% Utilities %%%
   % Converts first character to uppercase
  
positive.code: 
  % Sends an message as mod_copilot@localhost and
  % performs base64-encoding of the attributes
  route_to_copilot_component(To, Xml) ->
    ejabberd_router:route(?JID, To, Xml).
  
  route_to_copilot_component(From, To, Xml) ->
    ejabberd_router:route(From, To, hash_xml_body(Xml)).
  
  hash_xml_body({xmlelement, Tag, Attributes, ChildNodes}) ->
    {xmlelement,
  
negative.code:    {"event", Event},
     {Type, Value}].
  
  % Sends a reportEvent command to the Monitor
  report_event(Server, Event) ->
    To = gen_mod:get_module_opt(Server, ?MODULE, monitor_jid, "mon@localhost"),
    XmlBody = {xmlelement, "message", [{"from", ?JID},
  