anchor.diff:  %% -------------------------------------------------------------------------
   %% Internal Functions
   %% -------------------------------------------------------------------------
  -call_id(Mod, Config, Meta) when is_atom(Mod) ->
  -    call_id({Mod, []}, Config, Meta);
  -call_id({Mod, Opts}, Config, Scope) ->
  +call_id(#ct_hook_config{ module = Mod, opts = Opts} = Hook, Config, Scope) ->
       Id = catch_apply(Mod,id,[Opts], make_ref()),
  -    {Config, {Id, scope(Scope), {Mod, {Id,Opts}}}}.
  +    {Config, Hook#ct_hook_config{ id = Id, scope = scope(Scope)}}.
   	
  -call_init({Mod,{Id,Opts}},Config,_Meta) ->
  +call_init(#ct_hook_config{ module = Mod, opts = Opts, id = Id} = Hook,
  +	  Config,_Meta) ->
       NewState = Mod:init(Id, Opts),
  -    {Config, {Mod, NewState}}.
  -
  -call_terminate({Mod, State}, _, _) ->
  +    {Config, Hook#ct_hook_config{ state = NewState } }.
  +
  +call_terminate(#ct_hook_config{ module = Mod, state = State} = Hook, _, _) ->
       catch_apply(Mod,terminate,[State], ok),
  -    {[],{Mod,State}}.
  -
  -call_cleanup({Mod, State}, Reason, [Function, _Suite | Args]) ->
  +    {[],Hook}.
  +
  +call_cleanup(#ct_hook_config{ module = Mod, state = State} = Hook,
  +	     Reason, [Function, _Suite | Args]) ->
       NewState = catch_apply(Mod,Function, Args ++ [Reason, State],
   			   State),
  -    {Reason, {Mod, NewState}}.
  -
  -call_generic({Mod, State}, Value, [Function | Args]) ->
  +    {Reason, Hook#ct_hook_config{ state = NewState } }.
  +
  +call_generic(#ct_hook_config{ module = Mod, state = State} = Hook,
  +	     Value, [Function | Args]) ->
       {NewValue, NewState} = catch_apply(Mod, Function, Args ++ [Value, State],
   				       {Value,State}),
  -    {NewValue, {Mod, NewState}}.
  +    {NewValue, Hook#ct_hook_config{ state = NewState } }.
   
   %% Generic call function
   call(Fun, Config, Meta) ->
       maybe_lock(),
       Hooks = get_hooks(),
  -    Res = call([{HookId,Fun} || {HookId,_, _} <- Hooks] ++
  +    Res = call([{HookId,Fun} || #ct_hook_config{id = HookId} <- Hooks] ++
   		   get_new_hooks(Config, Fun),
   	       remove(?config_name,Config), Meta, Hooks),
       maybe_unlock(),
  
positive.code: 
  call([{Hook, call_id, NextFun} | Rest], Config, Meta, Hooks) ->
      try
  	{Config, {NewId, _, _} = NewHook} = call_id(Hook, Config, Meta),
  	{NewHooks, NewRest} = 
  	    case lists:keyfind(NewId, 1, Hooks) of
  		false when NextFun =:= undefined ->
  		    {Hooks ++ [NewHook],
  		     [{NewId, fun call_init/3} | Rest]};
  
negative.code: %% If you change this, remember to update ct_util:look -> stop clause as well.
  -define(config_name, ct_hooks).
  
  -record(ct_hook_config, {id, module, prio, scope, opts = [], state = []}).
  
  %% -------------------------------------------------------------------------
  %% API Functions
  %% -------------------------------------------------------------------------
  