anchor.diff:  			end
   		end,
   	    From ! {self(),make_priv_dir,Result},
  -	    run_test_case_msgloop(Ref,Pid,Terminate,
  -				  Comment,CurrConf,Status);
  +	    run_test_case_msgloop(St0);
   	{'EXIT',Pid,{Ref,Time,Value,Loc,Opts}} ->
  -	    RetVal = {Time/1000000,Value,mod_loc(Loc),Opts,Comment},
  -	    run_test_case_msgloop(Ref,Pid,
  -				  {true,RetVal},Comment,undefined,Status);
  +	    RetVal = {Time/1000000,Value,mod_loc(Loc),Opts},
  +	    St = setup_termination(RetVal, St0#st{config=undefined}),
  +	    run_test_case_msgloop(St);
   	{'EXIT',Pid,Reason} ->
  +	    Config0 = St0#st.config,
   	    case Reason of
   		{timetrap_timeout,TVal,Loc} ->
   		    %% convert Loc to form that can be formatted
   		    case mod_loc(Loc) of
   			{FwMod,FwFunc,framework} ->
   			    %% timout during framework call
  -			    spawn_fw_call(FwMod,FwFunc,CurrConf,Pid,
  +			    spawn_fw_call(FwMod,FwFunc,Config0,Pid,
   					  {framework_error,{timetrap,TVal}},
   					  unknown,self()),
  -			    run_test_case_msgloop(Ref,Pid,
  -						  Terminate,Comment,
  -						  undefined,Status);
  +			    run_test_case_msgloop(St0#st{config=undefined});
   			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
   			    %% a timetrap timeout
  -			    NewCurrConf =
  -				case CurrConf of
  -				    {{Mod,Func},Conf} ->
  -					EndConfPid =
  -					    call_end_conf(
  -					      Mod,Func,Pid,
  -					      {timetrap_timeout,TVal},
  -					      Loc1,[{tc_status,
  -						     {failed,
  -						      timetrap_timeout}}|Conf],
  -					      TVal),
  -					{EndConfPid,{Mod,Func},Conf};
  -				    _ ->
  -					{Mod,Func} = get_mf(Loc1),
  -					%% The framework functions mustn't
  -					%% execute on this group leader process
  -					%% or io will cause deadlock, so we
  -					%% spawn a dedicated process for the
  -					%% operation and let the group leader
  -					%% go back to handle io.
  -					spawn_fw_call(Mod,Func,CurrConf,Pid,
  -						      {timetrap_timeout,TVal},
  -						      Loc1,self()),
  -					undefined
  -				end,
  -			    run_test_case_msgloop(Ref,Pid,
  -						  Terminate,Comment,
  -						  NewCurrConf,Status)
  +			    #st{mf={Mod,Func}} = St0,
  +			    case Config0 of
  +				_ when is_list(Config0) ->
  +				    EndConfPid =
  +					call_end_conf(
  +					  Mod,Func,Pid,
  +					  {timetrap_timeout,TVal},
  +					  Loc1,[{tc_status,
  +						 {failed,
  +						  timetrap_timeout}}|
  +						Config0],
  +					  TVal),
  +				    St = St0#st{end_conf_pid=EndConfPid},
  +				    run_test_case_msgloop(St);
  +				undefined ->
  +				    %% The framework functions mustn't
  +				    %% execute on this group leader process
  +				    %% or io will cause deadlock, so we
  +				    %% spawn a dedicated process for the
  +				    %% operation and let the group leader
  +				    %% go back to handle io.
  +				    spawn_fw_call(Mod,Func,Config0,Pid,
  +						  {timetrap_timeout,TVal},
  +						  Loc1,self()),
  +				    run_test_case_msgloop(St0)
  +			    end
   		    end;
   		{timetrap_timeout,TVal,Loc,InitOrEnd} ->
  +		    #st{mf={Mod,_Func},config=CurrConf} = St0,
   		    case mod_loc(Loc) of
   			{FwMod,FwFunc,framework} ->
   			    %% timout during framework call
  
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: 	    exit(Pid,{testcase_aborted,Reason,Line}),
  	    erlang:yield(),
  	    From ! {self(),abort_current_testcase,ok},
  	    St = receive
  		     {'DOWN', Mon, process, Pid, _} ->
  			 St0
  		 after 10000 ->
  			 %% Pid is probably trapping exits, hit it harder...
  			 exit(Pid, kill),
  			 %% here's the only place we know Reason, so we save
  			 %% it as a comment, potentially replacing user data
  			 Error = lists:flatten(io_lib:format("Aborted: ~p",
  							     [Reason])),
  			 Error1 = lists:flatten([string:strip(S,left) ||
  						    S <- string:tokens(Error,
  								       [$\n])]),
  			 Comment = if length(Error1) > 63 ->
  					   string:substr(Error1,1,60) ++ "...";
  				      true ->
  					   Error1
  				   end,
  			 St0#st{comment=Comment}
  		 end,
  	    run_test_case_msgloop(St);
  	{sync_apply,From,MFA} ->
  	    sync_local_or_remote_apply(false,From,MFA),
  	    run_test_case_msgloop(St0);
  	{sync_apply_proxy,Proxy,From,MFA} ->
  	    sync_local_or_remote_apply(Proxy,From,MFA),
  	    run_test_case_msgloop(St0);
  	{comment,NewComment0} ->
  	    NewComment1 = test_server_ctrl:to_string(NewComment0),
  	    NewComment = test_server_sup:framework_call(format_comment,
  							[NewComment1],
  							NewComment1),
  	    run_test_case_msgloop(St0#st{comment=NewComment});
  	{read_comment,From} ->
  	    From ! {self(),read_comment,St0#st.comment},
  	    run_test_case_msgloop(St0);
  	{set_curr_conf,From,Config} ->
  	    From ! {self(),set_curr_conf,ok},
  	    St = St0#st{config=Config},
  	    run_test_case_msgloop(St);
  	{make_priv_dir,From} when St0#st.config =:= undefined ->
  	    From ! {self(),make_priv_dir,{error,no_priv_dir_in_config}},
  	    run_test_case_msgloop(St0);
  	{make_priv_dir,From} ->
  	    Result =
  		case proplists:get_value(priv_dir, St0#st.config) of
  		    undefined ->
  			{error,no_priv_dir_in_config};
  		    PrivDir ->
  