anchor.diff:      %% if the default port number was specified in there, but in practice that is
       %% what we have to do since some UAs can remove the port we put into the
       %% Record-Route
  -    Port = list_to_integer(siprequest:default_port(URI#sipurl.proto, URI#sipurl.port)),
  +    Port = siprequest:default_port(URI#sipurl.proto, sipurl:get_port(URI)),
       PortMatches = lists:member(Port, MyPorts),
       MAddrMatch = case dict:find("maddr", sipheader:param_to_dict(URI#sipurl.param)) of
   		     {ok, MyIP} -> true;
  
positive.code: 	P when integer(P) ->
  	    P;
  	none ->
  	    L = siprequest:default_port(Proto, none),
  	    list_to_integer(L)
      end;
  get_listenport(Proto) ->
      case sipserver:get_env(listenport, none) of
  	P when integer(P) ->
  	    P;
  	none ->
  	    L = siprequest:default_port(Proto, none),
  	    list_to_integer(L)
      end.
  
  %% In some places, we need to get a list of all ports which are valid for this proxy.
  
negative.code: 		_ ->
  		    true
  	    end,
  	    ok = init_mnesia(RemoteMnesiaTables),
  	    {ok, Supervisor} = sipserver_sup:start_extras(Supervisor, AppSupdata),
  	    {ok, Supervisor} = sipserver_sup:start_transportlayer(Supervisor),
  	    logger:log(normal, "proxy started"),
  	    {ok, Supervisor};
  	Unknown ->
  	    E = lists:flatten(io_lib:format("Failed starting supervisor : ~p", [Unknown])),
  	    {error, E}
      end.
  
  %%--------------------------------------------------------------------
  %% Function: init_mnesia(RemoteTables)
  %%           RemoteTables = list() of atom(), names of remote Mnesia
  %%                          tables needed by this Yxa application.
  %% Descrip.: Initiate Mnesia on this node. If there are no remote
  %%           mnesia-tables, we conclude that we are a mnesia master
  %%           and check if any of the tables needs to be updated.
  %% Returns : ok | does not return at all
  %%--------------------------------------------------------------------
  init_mnesia(none) ->
      %% update old database versions
      ok = table_update:update(),
      ok;
  init_mnesia(RemoteTables) when is_list(RemoteTables) ->
      DbNodes = case sipserver:get_env(databaseservers, none) of
  		  none ->
  		      logger:log(error, "Startup: This application needs remote tables ~p but you " ++
  				 "haven't configured any databaseservers, exiting.",
  				 [RemoteTables]),
  		      logger:quit(none),
  		      erlang:fault("No databaseservers configured");
  		  Res ->
  		      Res
  	      end,
      logger:log(debug, "Mnesia extra db nodes : ~p", [DbNodes]),
      case mnesia:change_config(extra_db_nodes,
  			      sipserver:get_env(databaseservers)) of
  	{error, Reason} ->
  	    logger:log(error, "Startup: Could not add configured databaseservers: ~p",
  		       [mnesia:error_description(Reason)]),
  	    logger:quit(none),
  	    erlang:fault("Could not add configured databaseservers");
  	_ ->
  	    true
      end,
      find_remote_mnesia_tables(RemoteTables).
  
  %%--------------------------------------------------------------------
  %% Function: find_remote_mnesia_tables(RemoteTables)
  %%           RemoteTables = list() of atom(), names of remote Mnesia
  %%                          tables needed by this Yxa application.
  %% Descrip.: Do mnesia:wait_for_tables() for RemoteTables, with a
  %%           timeout since we (Stockholm university) have had
  %%           intermittent problems with mnesia startups. Try a mnesia
  %%           stop/start after 30 seconds, and stop trying by using
  %%           erlang:fault() after another 30 seconds.
  %% Returns : ok | does not return at all
  %%
  %% XXX are the problems asociated with the somewhat random startup
  %% order of the nodes/applications? mnesia:start() is asynchronous
  %% or is it the usage of ctrl-c to terminate node when debugging
  %% which mnesia might perceive as a network error? - hsten
  %%--------------------------------------------------------------------
  find_remote_mnesia_tables(RemoteTables) ->
      logger:log(debug, "Initializing remote Mnesia tables ~p", [RemoteTables]),
      find_remote_mnesia_tables1(RemoteTables, RemoteTables, 0).
  
  find_remote_mnesia_tables1(OrigTableList, RemoteTables, Count) ->
      case mnesia:wait_for_tables(RemoteTables, 10000) of
  	ok ->
  	    ok;
  	{timeout, BadTabList} ->
  	    case Count of
  		3 ->
  