anchor.diff:  -spec handle_call(term(), from(), #state{}) ->
       gen_server_call(#state{}).
   
  -handle_call({start, AppId, Ref, Disp, Opts}, _From, State) ->
  +handle_call({start, AppId, AppPid, Ref, Disp, Opts}, _From, State) ->
       #state{servers=Servers, apps=Apps} = State,
  -    case nksip_transport_sup:get_pid(AppId) of
  -        AppPid when is_pid(AppPid) ->
  -            case lists:keytake(Ref, 1, Servers) of
  -                false ->
  -                    case do_start_server(Ref, Disp, Opts) of
  -                        {ok, WebPid} ->
  -                            AppMon = erlang:monitor(process, AppPid),
  -                            Apps1 = [{{AppId, Ref}, AppMon}|Apps],
  -                            State1 = State#state{apps=Apps1},
  -                            % We will receive a {webserver_started, _, _} msg
  -                            {reply, {ok, WebPid}, State1};
  -                        {error, Error} ->
  -                            {reply, {error, Error}, State}
  -                    end;
  -                {value, {_, WebApps, WebPid, WebMon}, Rest} ->
  -                    case lists:member(AppId, WebApps) of
  -                        true -> 
  -                            {reply, {error, already_started}, State};
  -                        false ->
  -                            Servers1 = [{Ref, [AppId|WebApps], WebPid, WebMon}|Rest],
  -                            AppMon = erlang:monitor(process, AppPid),
  -                            Apps1 = [{{AppId, Ref}, AppMon}|Apps],
  -                            State1 = State#state{servers=Servers1, apps=Apps1},
  -                            {reply, {ok, WebPid}, State1}
  -                    end
  +    App = #app_info{
  +        index = {AppId, Ref},
  +        dispatch = Disp,
  +        mon = erlang:monitor(process, AppPid)
  +    },
  +    case lists:keytake(Ref, #server_info.ref, Servers) of
  +        false ->
  +            case do_start_server(Ref, Disp, Opts) of
  +                {ok, WebPid} ->
  +                    % We will receive a {webserver_started, _, _} msg
  +                    State1 = State#state{apps=[App|Apps]},
  +                    {reply, {ok, WebPid}, State1};
  +                {error, Error} ->
  +                    {reply, {error, Error}, State}
               end;
  -        undefined ->
  -            {reply, {error, app_not_found}, State}
  +        {value, #server_info{apps=WebApps, pid=WebPid}=Server, Servers1} ->
  +            Apps1 = case lists:keytake({AppId, Ref}, #app_info.index, Apps) of
  +                false -> 
  +                    Apps;
  +                {value, #app_info{mon=AppMon}, RestApps} ->
  +                    erlang:demonitor(AppMon),
  +                    RestApps
  +            end,
  +            Apps2 = [App|Apps1],
  +            do_update_server(Ref, Apps2),
  +            WebApps1 = nksip_lib:store_value(AppId, WebApps),
  +            Server1 = Server#server_info{apps=WebApps1},
  +            State1 = State#state{
  +                servers = [Server1|Servers1], 
  +                apps = Apps2
  +            },
  +            {reply, {ok, WebPid}, State1}
       end;
   
   handle_call({stop, AppId, Ref}, _From, State) ->
       #state{servers=Servers, apps=Apps} = State,
  -    case lists:keytake(Ref, 1, Servers) of
  +    case lists:keytake(Ref, #server_info.ref, Servers) of
           false ->
               {reply, {error, not_found}, State};
  -        {value, {_, WebApps, WebPid, WebMon}, Rest} ->
  -            Apps1 = case lists:keytake({AppId, Ref}, 1, Apps) of
  -                false -> Apps;
  -                {value, {_, AppMon}, RestApps} -> erlang:demonitor(AppMon), RestApps
  +        {value, #server_info{apps=WebApps, mon=WebMon}=Server, Servers1} ->
  +            Apps1 = case lists:keytake({AppId, Ref}, #app_info.index, Apps) of
  +                false -> 
  +                    Apps;
  +                {value, #app_info{mon=AppMon}, RestApps} -> 
  +                    erlang:demonitor(AppMon), 
  +                    RestApps
               end,
               State1 = State#state{apps=Apps1},
               case lists:member(AppId, WebApps) of
  
positive.code:                    term(), nksip_lib:proplist()) ->
      {ok, pid()} | {error, term()}.
  
  start_server(AppId, Proto, Ip, Port, Disp, Opts) ->
      gen_server:call(?MODULE, {start, AppId, {Proto, Ip, Port}, Disp, Opts}).
  
  
  %% @doc Stops a started webserver
  
negative.code:                         [] ->
                              erlang:demonitor(WebMon),
                              Reply = do_stop_server(Ref),
                              {reply, Reply, State1#state{servers=Servers1}};
                          WebApps1 ->
                              do_update_server(Ref, Apps1),
                              Server1 = Server#server_info{apps=WebApps1},
                              {reply, ok, State1#state{servers=[Server1|Servers1]}}
                      end;
                  false ->
                      {reply, {error, not_found}, State1}
  