anchor.diff:      util:safe_signal("sipproxy :", Parent, {sipproxy_terminating, self()}),
       Res.
   
  -%%
  -%% No actions left
  -%%
  -fork(State) when record(State, state), State#state.actions == [] ->
  +
  +%%====================================================================
  +%% Internal functions
  +%%====================================================================
  +
  +%%--------------------------------------------------------------------
  +%% Function: fork(State)
  +%%           State = state record()
  +%% Descrip.: Main loop.
  +%% Returns : ok
  +%%--------------------------------------------------------------------
  +fork(State) when is_record(State, state), State#state.actions == [] ->
  +    %% No actions left
       OrigRequest = State#state.request,
       Targets = State#state.targets,
       {Method, ReqURI} = {OrigRequest#request.method, OrigRequest#request.uri},
  -    NewTargets = case allterminated(Targets) of
  -		     true ->
  -			 logger:log(debug, "sipproxy: All targets are terminated, staying alive to handle resends"),
  -			 Targets;
  -		     _ ->
  -			 logger:log(normal, "sipproxy: Reached end of Actions-list for ~s ~s, cancelling pending targets.",
  -				    [Method, sipurl:print(ReqURI)]),
  -			 NewTargets1 = cancel_pending_targets(Targets),
  -			 NewTargets1
  -    end,
  +    NewTargets =
  +	case allterminated(Targets) of
  +	    true ->
  +		logger:log(debug, "sipproxy: All targets are terminated, staying alive to handle resends"),
  +		Targets;
  +	    _ ->
  +		logger:log(normal, "sipproxy: Reached end of Actions-list for ~s ~s, cancelling pending targets.",
  +			   [Method, sipurl:print(ReqURI)]),
  +		NewTargets1 = cancel_pending_targets(Targets),
  +		NewTargets1
  +	end,
       util:safe_signal("sipproxy :", State#state.parent, {sipproxy_no_more_actions, self()}),
       logger:log(debug, "sipproxy: waiting ~p seconds for final responses", [State#state.timeout]),
  -    process_wait(false, State#state{mystate=stayalive, targets=NewTargets, endtime=util:timestamp() + State#state.timeout}),
  +    process_wait(false, State#state{mystate=stayalive, targets=NewTargets,
  +				    endtime=util:timestamp() + State#state.timeout}),
       ok;
  -fork(State) when record(State, state) ->
  +fork(State) when is_record(State, state) ->
  +    %% Process first action in list
       OrigRequest = State#state.request,
       [HAction | TAction] = State#state.actions,
       Method = OrigRequest#request.method,
  
positive.code: 	    CallURI = HAction#sipproxy_action.requri,
  	    CallTimeout = HAction#sipproxy_action.timeout,
  	    logger:log(debug, "sipproxy: forking ~s request to ~s with timeout ~p",
  		      [Method, sipurl:print(CallURI), CallTimeout]),
  	    Branch = State#state.branchbase ++ "-UAC" ++ integer_to_list(targetlist:list_length(Targets) + 1),
  	    Request = OrigRequest#request{uri=CallURI},
  	    DstList = sipdst:url_to_dstlist(CallURI, State#state.approx_msgsize, CallURI),
  	    [FirstDst|_] = DstList,
  	    NewTargets = case transactionlayer:start_client_transaction(Request, none, FirstDst, Branch, CallTimeout, self()) of
  	    	BranchPid when pid(BranchPid) ->
  		    targetlist:add(Branch, Request, BranchPid, calling, CallTimeout, DstList, Targets);
  		{error, E} ->
  		    logger:log(error, "sipproxy: Failed starting client transaction : ~p", [E]),
  		    Targets
  	    end,
  	    fork(State#state{actions=TAction, targets=NewTargets});
  	wait ->
  	    Time = HAction#sipproxy_action.timeout,
  	    logger:log(debug, "sipproxy: waiting ~p seconds", [Time]),
  	    case process_wait(false, State) of
  		{discontinue, NewState} ->
  		    logger:log(debug, "sipproxy: discontinue processing"),
  		    fork(NewState#state{actions=[]});
  
negative.code: 	    	    In ++ ".1"
  	    end
      end.
  
  %%--------------------------------------------------------------------
  %% Function: allterminated(State)
  %%           allterminated(TargetList)
  %%           State      = state record()
  %%           TargetList = targetlist record()
  %% Descrip.: Determine if all targets are terminated (that is, no
  %%           targets are in the states calling, trying or proceeding).
  %% Returns : true | false
  %%--------------------------------------------------------------------
  allterminated(State) when is_record(State, state) ->
      allterminated(State#state.targets);
  
  allterminated(TargetList) ->
      TargetsCalling = targetlist:get_targets_in_state(calling, TargetList),
      TargetsTrying = targetlist:get_targets_in_state(trying, TargetList),
  