anchor.diff:      end;
   call([{HookId, Fun} | Rest], Config, Meta, Hooks) ->
       try
  -        {_,Scope,ModState} = lists:keyfind(HookId, 1, Hooks),
  -        {NewConf, NewHookInfo} =  Fun(ModState, Config, Meta),
  +        Hook = lists:keyfind(HookId, #ct_hook_config.id, Hooks),
  +        {NewConf, NewHook} =  Fun(Hook, Config, Meta),
           NewCalls = get_new_hooks(NewConf, Fun),
  -        NewHooks = lists:keyreplace(HookId, 1, Hooks, {HookId, Scope, NewHookInfo}),
  +        NewHooks = lists:keyreplace(HookId, #ct_hook_config.id, Hooks, NewHook),
           call(NewCalls  ++ Rest, remove(?config_name, NewConf), Meta,
                terminate_if_scope_ends(HookId, Meta, NewHooks))
       catch throw:{error_in_cth_call,Reason} ->
  
positive.code: -spec init(State :: term()) -> ok |
  			       {error, Reason :: term()}.
  init(Opts) ->
      call([{Hook, call_id, undefined} || Hook <- get_new_hooks(Opts)],
  	 ok, init, []).
  		      
  
  %% @doc Called after all suites are done.
  -spec terminate(Hooks :: term()) ->
      ok.
  terminate(Hooks) ->
      call([{HookId, fun call_terminate/3} || {HookId,_,_} <- Hooks],
  	 ct_hooks_terminate_dummy, terminate, Hooks),
      ok.
  
  
negative.code: terminate_if_scope_ends(HookId, [Function,Tag|T], Hooks) when T =/= [] ->
      terminate_if_scope_ends(HookId,[Function,Tag],Hooks);
  terminate_if_scope_ends(HookId, Function, Hooks) ->
      case lists:keyfind(HookId, #ct_hook_config.id, Hooks) of
          #ct_hook_config{ id = HookId, scope = Function} = Hook ->
              terminate([Hook]),
              lists:keydelete(HookId, #ct_hook_config.id, Hooks);
          _ ->
              Hooks
      end.
  
  %% Fetch hook functions
  get_new_hooks(Config, Fun) ->
      lists:map(fun(NewHook) when is_atom(NewHook) ->
  		      {#ct_hook_config{ module = NewHook }, call_id, Fun};
  		 ({NewHook,Opts}) ->
  		      {#ct_hook_config{ module = NewHook,
  					opts = Opts}, call_id, Fun};
  		 ({NewHook,Opts,Prio}) ->
  		      {#ct_hook_config{ module = NewHook,
  					opts = Opts,
  					prio = Prio }, call_id, Fun}
  		end, get_new_hooks(Config)).
  
  get_new_hooks(Config) when is_list(Config) ->
      lists:flatmap(fun({?config_name, HookConfigs}) ->
  