anchor.diff:  	    } = YxaCtx,
       case local:pstnproxy_number_based_routing(Request, THandler, LogTag, PstnCtx) of
   	undefined ->
  -	    Base =
  +	    This =
   		case is_tagged(from_gateway, PstnCtx) of
   		    true ->
  -			[{lookup, local},
  -			 {lookup, enum},
  +			[{lookup, enum},
   			 {lookup, sipproxy}
   			];
   		    false ->
   			%% not from one of our PSTN gateways
  -			[{lookup, local},
  +			[{lookup, to_pstngw},
   			 {lookup, pstn},
   			 {lookup, not_e164},
   			 {lookup, default_pstngateway}
   			]
   		end,
  -	    Base ++ [{response, 404, "Not Found", []}];
  +	    [{lookup, local}] ++ This ++ [{response, 404, "Not Found", []}];
   	Res when is_list(Res) ->
   	    Res
       end.
  
positive.code: 	    error -> PstnCtx#pstn_ctx.called_number;
  	    N when is_list(N) -> N
  	end,
      {ok, Classdefs} = yxa_config:get_env(classdefs),
      {ok, Class} = sipauth:classify_number(DstNumber, Classdefs),
      {ok, UnauthClasses} = yxa_config:get_env(sipauth_unauth_classlist),
      User = PstnCtx#pstn_ctx.user,
      PstnCtx1 =
  	PstnCtx#pstn_ctx{dst_number = DstNumber,
  			 dst_class  = Class
  			},
      case lists:member(Class, UnauthClasses) of
  	true ->
  	    logger:log(normal, "~s: pstnproxy: Allowing request from user ~p to number available to anyone "
  		       "(~s, class '~p')", [YxaCtx#yxa_ctx.app_logtag, User, DstNumber, Class]),
  	    {ok, true, PstnCtx1};
  	false when is_list(User) ->
  	    case local:is_allowed_pstn_dst(User, DstNumber, Request#request.header, Class) of
  		true ->
  		    Verdict = check_auth_for_allowed_pstn_dst(Request, YxaCtx, PstnCtx1),
  		    {ok, Verdict, PstnCtx1};
  		false ->
  		    logger:log(normal, "~s: pstnproxy: User ~p NOT allowed request to number ~s, class '~p'",
  			       [YxaCtx#yxa_ctx.app_logtag, User, DstNumber, Class]),
  		    transactionlayer:send_response_handler(YxaCtx#yxa_ctx.thandler, 403, "Forbidden", []),
  		    {ok, false, PstnCtx1}
  	    end;
  	false when User == undefined ->
  	    Verdict = check_unauth_request_to_pstn_dst(Request, YxaCtx, PstnCtx1),
  	    {ok, Verdict, PstnCtx1}
      end.
  
  %% part of authorize_user_call_to_pstn/3
  %% Returns: true | false
  
negative.code: 	    {ok, Action, NewPstnCtx};
  	undefined ->
  	    nomatch
      end;
  
  %%--------------------------------------------------------------------
  %% Function: perform_lookup(to_pstngw, Request, PstnCtx)
  %%           Request = request record()
  %%           PstnCtx = pstn_ctx record()
  %% Descrip.: Check if request is addressed directly to one of our
  %%           PSTN gateways, and if we should allow it based solely on
  %%           that.
  %% Returns : {ok, {proxy, Dst}, NewPstnCtx} |
  %%           nomatch
  %%           Dst        = sipurl record()
  %%           NewPstnCtx = pstn_ctx record()
  %%--------------------------------------------------------------------
  perform_lookup(to_pstngw, Request, PstnCtx) ->
      ToHost = (Request#request.uri)#sipurl.host,
      case is_pstngateway(ToHost) of
  	true ->
  	    logger:log(debug, "pstnproxy: Routing request to specified PSTN gateway : ~s",
  		       [ToHost]),
  	    NewPstnCtx =
  		PstnCtx#pstn_ctx{destination   = pstn
  				},
  	    {ok, {proxy, Request#request.uri}, NewPstnCtx};
  	false ->
  	    nomatch
      end.
  
  %%--------------------------------------------------------------------
  %% Function: authorize_proxying(Request, YxaCtx, PstnCtx)
  