anchor.diff:  	    locations_to_actions(Locations);
   	Unknown ->
   	    logger:log(error, "Appserver: Unexpected result from get_locations_for_users(~p) in fetch_users_locations_as_actions",
  -			[Users]),
  +		       [Users]),
   	    throw({siperror, 500, "Server Internal Error"})
       end.
   
   locations_to_actions(L) ->
       locations_to_actions2(L, []).
  -    
  +
   locations_to_actions2([], Res) ->
       Res;
   locations_to_actions2([{Location, Flags, Class, Expire} | T], Res) ->
  
positive.code: 	    transportlayer:send_proxy_request(THandler, CompatRequest, URI, [])
      end.
  
  %% Function: response/3
  %% Description: Yxa applications must export an response/3 function.
  %% Returns: See XXX
  %%--------------------------------------------------------------------
  response(Response, Origin, LogStr) when record(Response, response), record(Origin, siporigin) ->
      % RFC 3261 16.7 says we MUST act like a stateless proxy when no
      % transaction can be found
      CompatResponse = {Response#response.status, Response#response.reason, Response#response.header, Response#response.body},
      Status = Response#response.status,
      Reason = Response#response.reason,
      case transactionlayer:get_server_handler_for_stateless_response(CompatResponse) of
  	{error, E} ->
  	    logger:log(error, "Failed getting server transaction for stateless response: ~p", [E]),
  	    logger:log(normal, "Response to ~s: ~p ~s, failed fetching state - proxying", [LogStr, Status, Reason]),
  	    transportlayer:send_proxy_response(none, CompatResponse);
  	none ->
  	    logger:log(normal, "Response to ~s: ~p ~s, found no state - proxying", [LogStr, Status, Reason]),
  	    transportlayer:send_proxy_response(none, CompatResponse);
  	TH ->
  	    logger:log(debug, "Response to ~s: ~p ~s, server transaction ~p", [LogStr, Status, Reason, TH]),
  	    transactionlayer:send_proxy_response_handler(TH, CompatResponse)
      end.
  
  get_actions(URI) ->
      {User, Pass, Host, Port, Parameters} = URI,
      LookupURL = {User, none, Host, none, []},
  
negative.code: 
      {Res, NewState} = receive
  
  			  {sipproxy_response, ForkPid, Branch, Response} ->
  			      NewState1 = handle_sipproxy_response(Response, State),
  			      {ok, NewState1};
  
  			  {servertransaction_cancelled, CallHandlerPid} ->
  			      logger:log(debug, "Appserver glue: Original request has been cancelled, sending 'cancel_pending' to ForkPid ~p and entering state 'cancelled'",
  					 [ForkPid]),
  			      util:safe_signal("Appserver: ", ForkPid, {cancel_pending}),
  			      NewState1 = State#state{cancelled=true},
  			      {ok, NewState1};
  
  			  {all_terminated, FinalResponse} ->
  			      NewState1 = case State#state.cancelled of
  					      true ->
  						  logger:log(debug, "Appserver glue: received all_terminated - request was cancelled. " ++
  							     "Ask CallHandler ~p to send 487 Request Terminated and entering state 'completed'",
  							     [CallHandler]),
  						  transactionlayer:send_response_handler(CallHandler, 487, "Request Cancelled"),
  						  State#state{completed=true};
  					      _ ->
  						  case FinalResponse of
  						      {Status, Reason, _, _} ->
  							  logger:log(debug, "Appserver glue: received all_terminated with a ~p ~s response (completed: ~p)",
  								     [Status, Reason, State#state.completed]),
  							  NewState2 = handle_sipproxy_response(FinalResponse, State),
  							  NewState2;
  						      {Status, Reason} ->
  							  logger:log(debug, "Appserver glue: received all_terminated - asking CallHandler ~p to answer ~p ~s",
  								     [CallHandler, Status, Reason]),
  							  transactionlayer:send_response_handler(CallHandler, Status, Reason),
  						% XXX check that this is really a final response?
  							  State#state{completed=true};
  						      none ->
  							  logger:log(debug, "Appserver glue: received all_terminated with no final answer"),
  							  State
  						  end
  					  end,
  			      {ok, NewState1};
  
  			  {no_more_actions} ->
  			      NewState1 = case State#state.cancelled of
  					      true ->
  						  logger:log(debug, "Appserver glue: received no_more_actions when cancelled. Ask CallHandler ~p to send 487 Request Terminated",
  							     [CallHandler]),
  						  transactionlayer:send_response_handler(CallHandler, 487, "Request Terminated"),
  						  State#state{completed=true};
  					      _ ->
  						  case State#state.completed of
  						      false ->
  							  {Method, URI, _, _} = State#state.request,
  							  logger:log(debug, "Appserver glue: received no_more_actions when NOT cancelled (and not completed), " ++
  								     "responding 408 Request Timeout to original request ~s ~s",
  								     [Method, sipurl:print(URI)]),
  							  transactionlayer:send_response_handler(CallHandler, 408, "Request Timeout"),
  							  State#state{completed=true};
  						      _ ->
  							  logger:log(debug, "Appserver glue: received no_more_actions when already completed - ignoring"),
  							  State
  						  end
  					  end,
  			      {ok, NewState1};
  
  			  {callhandler_terminating, ForkPid} ->
  			      logger:log(debug, "Appserver glue: received callhandler_terminating from my ForkPid ~p (CallHandlerPid is ~p) - setting ForkPid to 'none'",
  					 [ForkPid, CallHandlerPid]),
  			      NewState1 = State#state{forkpid=none},
  			      NewState2 = case util:safe_is_process_alive(CallHandler) of
  					      {true, _} ->
  						  case NewState1#state.completed of
  						      false ->
  							  logger:log(error, "Appserver glue: No answer to original request, answer 500 Server Internal Error"),
  							  transactionlayer:send_response_handler(CallHandler, 500, "Server Internal Error"),
  							  NewState1#state{completed=true};
  						      _ ->
  							  NewState1
  						  end;
  					      _ ->
  						  NewState1
  					  end,
  			      {ok, NewState2};
  
  			  {servertransaction_terminating, CallHandlerPid} ->
  			      logger:log(debug, "Appserver glue: received serverbranch_terminating from my CallHandlerPid ~p (ForkPid is ~p) - " ++
  					 "setting CallHandler to 'none'", [CallHandlerPid, ForkPid]),
  			      NewState1 = State#state{callhandler=none},
  			      {ok, NewState1};
  
  			  {quit} ->
  			      {quit, State};
  
  			  Unknown ->
  			      logger:log(error, "Appserver: Received unknown signal in process_messages() :~n~p", [Unknown]),
  			      {error, State}
  
  		      after
  			  300 * 1000 ->
  			      logger:log(debug, "Appserver glue: Still alive after 5 minutes! CallHandler ~p, ForkPid ~p", [CallHandler, ForkPid]),
  			      util:safe_signal("Appserver: ", ForkPid, {showtargets}),
  			      NewCallHandler = garbage_collect_transaction("CallHandler", CallHandler),
  			      NewForkPid = garbage_collect_pid("ForkPid", ForkPid),
  			      NewState1 = State#state{callhandler=NewCallHandler, forkpid=NewForkPid},
  			      {error, NewState1}
  		      end,
      case Res of
  	quit ->
  	    logger:log(debug, "Appserver glue: Quitting process_messages()"),
  