anchor.diff:                     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}).
  +start_server(AppId, Proto, Ip, Port, Disp, Opts) 
  +        when 
  +            (Proto==tcp orelse Proto==tls orelse Proto==ws orelse Proto==wss) andalso
  +            is_list(Disp) andalso is_list(Opts) ->
  +    case nksip_transport_sup:get_pid(AppId) of
  +        AppPid when is_pid(AppPid) ->
  +            Ref = {Proto, Ip, Port},
  +            gen_server:call(?MODULE, {start, AppId, AppPid, Ref, Disp, Opts});
  +        _ ->
  +            {error, sipapp_not_found}
  +    end.
   
   
   %% @doc Stops a started webserver
  
positive.code: -spec handle_call(term(), from(), #state{}) ->
      gen_server_call(#state{}).
  
  handle_call({start, AppId, 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
              end;
          undefined ->
              {reply, {error, app_not_found}, State}
      end;
  
  handle_call({stop, AppId, Ref}, _From, State) ->
      #state{servers=Servers, apps=Apps} = State,
      case lists:keytake(Ref, 1, 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
              end,
              State1 = State#state{apps=Apps1},
              case lists:member(AppId, WebApps) of
  
negative.code: 
  handle_cast({webserver_started, Ref, WebPid}, State) ->
      #state{apps=Apps, servers=Servers} = State,
      WebApps = [AppId || #app_info{index={AppId, WebRef}} <- Apps, WebRef==Ref],
      Server = #server_info{
          ref = Ref, 
          apps = WebApps, 
          pid = WebPid, 
          mon = erlang:monitor(process, WebPid)
      },
      {noreply, State#state{servers=[Server|Servers]}};
  
  handle_cast(stop_all, State) ->
      nksip_webserver_sup:terminate_all(),
  