anchor.diff:  			    logger:log(debug, "Lookup: User ~p has a CPL script, but I could not find an appserver",
   				       [User]),
   			    %% Fallback to just looking in the location database
  -			    lookupuser_locations([User], URL)
  +			    lookupuser_get_locations([User], URL)
   		    end;
   		false ->
  -		    lookupuser_locations([User], URL)
  +		    lookupuser_get_locations([User], URL)
   	    end;
   	Users when is_list(Users) ->
  -	    lookupuser_locations(Users, URL)
  +	    %% multiple (or no) users
  +	    lookupuser_get_locations(Users, URL)
       end.
   
   %% part of lookupuser()
  -lookupuser_locations(Users, URL) ->
  -    case local:get_locations_for_users(Users) of
  -	Locations1 when is_list(Locations1) ->
  -	    Locations2 = local:prioritize_locations([Users], Locations1),
  -	    Locations = local:remove_unsuitable_locations(URL, Locations2),
  -	    %% check if more than one location was found.
  -	    case Locations of
  -	        [] ->
  -		    %% User exists but has no currently known locations
  -		    case local:lookupregexproute(sipurl:print(URL)) of
  -			none ->
  -			    logger:log(debug, "Lookup: No locations found for URL ~p, and no matching regexp rules.",
  -				       [sipurl:print(URL)]),
  -			    none;
  -			Loc ->
  -			    logger:log(debug, "Lookup: Regexp-route lookup of ~p -> ~p", [sipurl:print(URL), Loc]),
  -		            Loc
  -		    end;
  -		[#siplocationdb_e{address=BestLocation}] when is_record(BestLocation, sipurl) ->
  -		    %% A single location was found in the location database (after removing any unsuitable ones)
  -		    {proxy, BestLocation};
  -		[Location | _] when is_record(Location, siplocationdb_e) ->
  -		    %% More than one location registered for this address, check for appserver...
  -		    %% (appserver is the program that handles forking of requests)
  -		    local:lookupappserver(URL)
  -	    end
  -    end.
  -
  +lookupuser_get_locations(Users, URL) ->
  +    %% check if more than one location was found.
  +    case local:lookupuser_locations(Users, URL) of
  +	[] ->
  +	    %% User exists but has no currently known locations
  +	    NoParamURL = sipurl:set([{param, []}], URL),
  +	    case local:lookupregexproute(sipurl:print(NoParamURL)) of
  +		none ->
  +		    logger:log(debug, "Lookup: No locations found for users ~p, and no regexp rules match URL ~p.",
  +			       [Users, sipurl:print(NoParamURL)]),
  +		    none;
  +		{proxy, Loc} ->
  +		    logger:log(debug, "Lookup: Regexp-route rewrite of ~p -> ~p",
  +			       [sipurl:print(NoParamURL), sipurl:print(Loc)]),
  +		    {proxy, Loc}
  +	    end;
  +	[#siplocationdb_e{address=BestLocation}] when is_record(BestLocation, sipurl) ->
  +	    %% A single location was found in the location database (after removing any unsuitable ones)
  +	    {proxy, BestLocation};
  +	[Location | _] when is_record(Location, siplocationdb_e) ->
  +	    %% More than one location registered for this address, check for appserver...
  +	    %% (appserver is the program that handles forking of requests)
  +	    local:lookupappserver(URL)
  +    end.
  +
  +%%--------------------------------------------------------------------
  +%% Function: lookupuser_locations(Users, URL)
  +%%           Users = list() of string(), SIP users to fetch locations
  +%%                                       of
  +%%           URL   = sipurl record(), the Request-URI
  +%% Descrip.: Return all locations for a list of users that is suitable
  +%%           given a Request-URI. By suitable, we mean that we filter
  +%%           out SIP locations if Request-URI was SIPS, unless this
  +%%           proxy is configured not to.
  +%% Returns : Locations = list() of siplocationdb_e record()
  +%%--------------------------------------------------------------------
  +lookupuser_locations(Users, URL) when is_list(Users), is_record(URL, sipurl) ->
  +    Locations1 = local:get_locations_for_users(Users),
  +    Locations = local:prioritize_locations(Users, Locations1),
  +    local:remove_unsuitable_locations(URL, Locations).
  +    
   %%--------------------------------------------------------------------
   %% Function: remove_unsuitable_locations(URL, Locations)
   %%           URL      = sipurl record(), Request-URI of request
  
positive.code: %%--------------------------------------------------------------------
  isours(URL) when is_record(URL, sipurl) ->
      case local:get_users_for_url(URL) of
  	[] ->
  	    logger:log(debug, "Lookup: isours ~s -> false", [sipurl:print(URL)]),
  	    false;
  	nomatch ->
  	    logger:log(debug, "Lookup: isours ~s -> false", [sipurl:print(URL)]),
  	    false;
  	Users when is_list(Users) ->
  	    logger:log(debug, "Lookup: isours ~s -> user(s) ~p", [sipurl:print(URL), Users]),
  	    true;
  	Unknown ->
  	    logger:log(debug, "Lookup: isours ~s -> Unknown result ~p", [sipurl:print(URL), Unknown]),
  	    false
      end.
  
  %%--------------------------------------------------------------------
  
negative.code:     Unsuitable_URL1 = sipurl:new([{proto, "sip"}, {host, "sip1.example.org"}]),
      Unsuitable_URL2 = sipurl:new([{proto, "sips"}, {host, "sips1.example.org"}]),
      Unsuitable_URL3 = sipurl:new([{proto, "sip"}, {host, "sip2.example.org"}]),
      Unsuitable_URL4 = sipurl:new([{proto, "sip"}, {host, "sip2.example.org"}, {param, ["transport=tls"]}]),
  
      Unsuitable_LDBE1 = #siplocationdb_e{address=Unsuitable_URL1},
      Unsuitable_LDBE2 = #siplocationdb_e{address=Unsuitable_URL2},
      Unsuitable_LDBE3 = #siplocationdb_e{address=Unsuitable_URL3},
      Unsuitable_LDBE4 = #siplocationdb_e{address=Unsuitable_URL4},
  
      io:format("test: remove_unsuitable_locations/2 - 1~n"),
      %% test with non-SIPS URI, no entrys should be removed
  