anchor.diff:  			    spawn_fw_call(FwMod,FwFunc,CurrConf,Pid,
   					  {framework_error,ErrorMsg},
   					  unknown,self()),
  -			    run_test_case_msgloop(Ref,Pid,
  -						  Terminate,Comment,
  -						  undefined,Status);
  +			    St = St0#st{config=undefined},
  +			    run_test_case_msgloop(St);
   			Loc1 ->
   			    %% call end_per_testcase on a separate process,
   			    %% only so that the user has a chance to clean up
   			    %% after init_per_testcase, even after abortion
  -			    NewCurrConf =
  -				case CurrConf of
  -				    {{Mod,Func},Conf} ->
  -					TVal =
  -					    case lists:keysearch(default_timeout,
  -								 1,
  -								 Conf) of
  -						{value,{default_timeout,Tmo}} ->
  -						    Tmo;
  -						_ ->
  -						    ?DEFAULT_TIMETRAP_SECS*1000
  -					    end,
  -					EndConfPid =
  -					    call_end_conf(
  -					      Mod,Func,Pid,
  -					      ErrorMsg,Loc1,
  -					      [{tc_status,
  -						{failed,ErrorMsg}}|Conf],TVal),
  -					{EndConfPid,{Mod,Func},Conf};
  -				    _ ->
  -					{Mod,Func} = get_mf(Loc1),
  -					spawn_fw_call(Mod,Func,CurrConf,Pid,
  -						      ErrorMsg,Loc1,self()),
  -					undefined
  -				end,
  -			    run_test_case_msgloop(Ref,Pid,
  -						  Terminate,Comment,
  -						  NewCurrConf,Status)
  +			    case CurrConf of
  +				_ when is_list(CurrConf) ->
  +				    TVal =
  +					case lists:keyfind(default_timeout,
  +							   1,
  +							   CurrConf) of
  +					    {default_timeout,Tmo} ->
  +						Tmo;
  +					    _ ->
  +						?DEFAULT_TIMETRAP_SECS*1000
  +					end,
  +				    EndConfPid =
  +					call_end_conf(
  +					  Mod,Func,Pid,
  +					  ErrorMsg,Loc1,
  +					  [{tc_status,
  +					    {failed,ErrorMsg}}|CurrConf],
  +					  TVal),
  +				    St = St0#st{end_conf_pid=EndConfPid},
  +				    run_test_case_msgloop(St);
  +				undefined ->
  +				    spawn_fw_call(Mod,Func,CurrConf,Pid,
  +						  ErrorMsg,Loc1,self()),
  +				    run_test_case_msgloop(St0)
  +			    end
   		    end;
   		killed ->
   		    %% result of an exit(TestCase,kill) call, which is the
   		    %% only way to abort a testcase process that traps exits
   		    %% (see abort_current_testcase)
  -		    {Mod,Func} = case CurrConf of
  -				     {MF,_} -> MF;
  -				     _      -> {undefined,undefined}
  -				 end,
  +		    #st{mf={Mod,Func},config=CurrConf} = St0,
   		    spawn_fw_call(Mod,Func,CurrConf,Pid,
   				  testcase_aborted_or_killed,
   				  unknown,self()),
  -		    run_test_case_msgloop(Ref,Pid,
  -					  Terminate,Comment,CurrConf,Status);
  +		    run_test_case_msgloop(St0);
   		{fw_error,{FwMod,FwFunc,FwError}} ->
  +		    #st{config=CurrConf} = St0,
   		    spawn_fw_call(FwMod,FwFunc,CurrConf,Pid,
   				  {framework_error,FwError},
   				  unknown,self()),
  -		    run_test_case_msgloop(Ref,Pid,
  -					  Terminate,Comment,CurrConf,Status);
  +		    run_test_case_msgloop(St0);
   		_Other ->
   		    %% the testcase has terminated because of Reason (e.g. an exit
   		    %% because a linked process failed)
  -		    {Mod,Func} = case CurrConf of
  -				     {MF,_} -> MF;
  -				     _      -> {undefined,undefined}
  -				 end,
  +		    #st{mf={Mod,Func},config=CurrConf} = St0,
   		    spawn_fw_call(Mod,Func,CurrConf,Pid,
   				  Reason,unknown,self()),
  -		    run_test_case_msgloop(Ref,Pid,
  -					  Terminate,Comment,CurrConf,Status)
  +		    run_test_case_msgloop(St0)
   	    end;
  -	{EndConfPid,{call_end_conf,Data,_Result}} ->
  +	{EndConfPid0,{call_end_conf,Data,_Result}} ->
  +	    #st{mf={Mod,Func},config=CurrConf} = St0,
   	    case CurrConf of
  -		{EndConfPid,{Mod,Func},_Conf} ->
  +		_ when is_list(CurrConf) ->
   		    {_Mod,_Func,TCPid,TCExitReason,Loc} = Data,
   		    spawn_fw_call(Mod,Func,CurrConf,TCPid,
   				  TCExitReason,Loc,self()),
  -		    run_test_case_msgloop(Ref,Pid,
  -					  Terminate,Comment,undefined,Status);
  +		    St = St0#st{config=undefined,end_conf_pid=undefined},
  +		    run_test_case_msgloop(St);
   		_ ->
  -		    run_test_case_msgloop(Ref,Pid,
  -					  Terminate,Comment,CurrConf,Status)
  +		    run_test_case_msgloop(St0)
   	    end;
   	{_FwCallPid,fw_notify_done,{T,Value,Loc,Opts,AddToComment}} ->
   	    %% the framework has been notified, we're finished
  -	    RetVal =
  -		case AddToComment of
  -		    undefined ->
  -			{T,Value,Loc,Opts,Comment};
  -		    _ ->
  -			Comment1 =
  -			    if Comment == "" -> 
  -				    AddToComment;
  -			       true -> 
  -				    Comment ++
  -				    test_server_ctrl:xhtml("<br>",
  -							   "<br />") ++
  -				    AddToComment
  -			    end,
  -			{T,Value,Loc,Opts,Comment1}
  -		end,
  -	    run_test_case_msgloop(Ref,Pid,
  -				  {true,RetVal},Comment,undefined,Status);
  +	    RetVal = {T,Value,Loc,Opts},
  +	    Comment0 = St0#st.comment,
  +	    Comment = case AddToComment of
  +			  undefined ->
  +			      Comment0;
  +			  _ ->
  +			      if Comment0 =:= "" ->
  +				      AddToComment;
  +				 true -> 
  +				      Comment0 ++
  +					  test_server_ctrl:xhtml("<br>",
  +								 "<br />") ++
  +					  AddToComment
  +			      end
  +		      end,
  +	    St = setup_termination(RetVal, St0#st{comment=Comment,
  +						  config=undefined}),
  +	    run_test_case_msgloop(St);
    	{'EXIT',_FwCallPid,{fw_notify_done,Func,Error}} ->
   	    %% a framework function failed
   	    CB = os:getenv("TEST_SERVER_FRAMEWORK"),
  
positive.code: 			ok
  		end,
  		Conf = [{tc_status,{failed,timetrap_timeout}}],
  		case catch do_end_tc_call(Mod1,Func1, Loc,
  					  {Pid,Error,[Conf]},Error) of
  		    {'EXIT',FwEndTCErr} ->
  			exit({fw_notify_done,end_tc,FwEndTCErr});
  
negative.code: 	    end
      end.
  
  -record(st,
  	{
  	  ref :: reference(),
  	  pid :: pid(),
  	  mf :: {atom(),atom()},
  	  status :: 'starting' | 'running',
  	  ret_val :: term(),
  	  comment :: list(char()),
  	  timeout :: non_neg_integer() | 'infinity',
  	  config :: list() | 'undefined',
  	  end_conf_pid :: pid() | 'undefined'
  	}).
  
  do_run_test_case_apply(Mod, Func, Args, Name, RunInit, TimetrapData) ->
      {ok,Cwd} = file:get_cwd(),
      Args2Print = case Args of
  