anchor.diff:  	    throw({siperror, 500, "Server Internal Error"})
       end.
   
  +%% forward_call_actions/2 helps fetch_actions_for_users/1 make a list of
  +%% sipproxy_action out of a list of forwards, a timeout value and
  +%% "concurrent ringing or not" information
   forward_call_actions([{Forwards, Timeout, Localring}], Actions) ->
       FwdTimeout = sipserver:get_env(appserver_forward_timeout, 40),
       Func = fun(Forward) ->
  
positive.code: 	[] ->
  	    Actions;
  	{aborted, {no_exists, forward}} ->
  	    Actions;
  	Forwards when list(Forwards) ->
  	    forward_call_actions(Forwards, Actions);
  
negative.code:     logger:log(error, "appserver: Illegal location in locations_to_actions2: ~p", [H]),
      locations_to_actions2(T, Res).
  
  %%--------------------------------------------------------------------
  %% Function: fork_actions(BranchBase, CallHandler, Request, Actions)
  %%           BranchBase = string()
  %%           CallHandler = term(), reference to server transaction
  %%           Request = request record()
  %%           Actions = list() of sipproxy_action record()
  %% Descrip.: Start start_actions/4 in a new thread, then enter the
  %%           process_messages() loop. Do not return until fork is
  %%           done (meaning both server transaction and all client
  %%           transactions are finished or dead). Execution process is
  %%           the one we refer to as appserver glue process.
  %% Returns : ok
  %%--------------------------------------------------------------------
  fork_actions(BranchBase, CallHandler, Request, Actions) when record(Request, request) ->
      {Method, URI} = {Request#request.method, Request#request.uri},
      ForkPid = sipserver:safe_spawn(fun start_actions/4, [BranchBase, self(), Request, Actions]),
      logger:log(normal, "~s: Appserver: Forking request, ~p actions",
  	       [BranchBase, length(Actions)]),
      logger:log(debug, "Appserver: Forking request, glue process ~p, CallHandler ~p, ForkPid ~p",
  	       [self(), CallHandler, ForkPid]),
      InitState = #state{request=Request, sipmethod=Method, callhandler=CallHandler, forkpid=ForkPid, cancelled=false, completed=false},
      process_messages(InitState),
      logger:log(normal, "Appserver glue: Finished with fork (~s ~s), exiting.", [Method, sipurl:print(URI)]),
      ok.
  
  start_actions(BranchBase, GluePid, OrigRequest, Actions) when record(OrigRequest, request) ->
      {Method, URI} = {OrigRequest#request.method, OrigRequest#request.uri},
      Timeout = 32,
      %% We don't return from sipproxy:start() until all Actions are done, and sipproxy signals GluePid
      %% when it is done.
      case sipproxy:start(BranchBase, GluePid, OrigRequest, Actions, Timeout) of
  	ok ->
  	    logger:log(debug, "Appserver forker : sipproxy fork of request ~s ~s done, start_actions() returning", [Method, sipurl:print(URI)]),
  	    true;
  	{error, What} ->
  	    logger:log(error, "Appserver forker : sipproxy fork of request ~s ~s failed : ~p", [Method, sipurl:print(URI), What]),
  	    transactionlayer:send_response_request(OrigRequest, 500, "Server Internal Error")
      end.
  
  %% Receive messages from branch pids and do whatever is necessary with them
  process_messages(State) when record(State, state), State#state.callhandler == none, State#state.forkpid == none ->
      logger:log(debug, "Appserver glue: Both CallHandler and ForkPid are 'none' - terminating"),
      ok;
  process_messages(State) when record(State, state) ->
  