anchor.diff:      Parent = gen:get_parent(),
       Debug = gen:debug_options(Name, Options),
       HibernateAfterTimeout = gen:hibernate_after(Options),
  -    loop(Parent, Name, State, Mod, Continue, HibernateAfterTimeout, Debug).
  +    CbCache = create_callback_cache(Mod),
  +    loop(Parent, Name, State, CbCache, Continue, HibernateAfterTimeout, Debug).
   
   %%%========================================================================
   %%% Gen-callback functions
  
positive.code: 	( (X) =:= infinity orelse ( is_integer(X) andalso (X) >= 0 ) )
  ).
  
  %%%=========================================================================
  %%%  API
  %%%=========================================================================
  
negative.code: %%% Message handling functions
  %%% ---------------------------------------------------
  
  handle_msg({'$gen_call', From, Msg}, Parent, Name, State, CbCache, HibernateAfterTimeout) ->
      Result = try_handle_call(CbCache, Msg, From, State),
      case Result of
  	{ok, {reply, Reply, NState}} ->
  	    reply(From, Reply),
  	    loop(Parent, Name, NState, CbCache, infinity, HibernateAfterTimeout, []);
  	{ok, {reply, Reply, NState, TimeoutOrHibernate}}
            when ?is_timeout(TimeoutOrHibernate);
                 TimeoutOrHibernate =:= hibernate ->
  	    reply(From, Reply),
  	    loop(Parent, Name, NState, CbCache, TimeoutOrHibernate, HibernateAfterTimeout, []);
  	{ok, {reply, Reply, NState, {continue, _}=Continue}} ->
  	    reply(From, Reply),
  	    loop(Parent, Name, NState, CbCache, Continue, HibernateAfterTimeout, []);
  	{ok, {stop, Reason, Reply, NState}} ->
  	    try
              Mod = CbCache#callback_cache.module,
  		terminate(Reason, ?STACKTRACE(), Name, From, Msg, Mod, NState, [])
  	    after
  		reply(From, Reply)
  	    end;
  	Other -> handle_common_reply(Other, Parent, Name, From, Msg, CbCache, HibernateAfterTimeout, State)
      end;
  handle_msg(Msg, Parent, Name, State, CbCache, HibernateAfterTimeout) ->
      Reply = try_dispatch(Msg, CbCache, State),
      handle_common_reply(Reply, Parent, Name, undefined, Msg, CbCache, HibernateAfterTimeout, State).
  
  handle_msg({'$gen_call', From, Msg}, Parent, Name, State, CbCache, HibernateAfterTimeout, Debug) ->
      Result = try_handle_call(CbCache, Msg, From, State),
      case Result of
  	{ok, {reply, Reply, NState}} ->
  	    Debug1 = reply(Name, From, Reply, NState, Debug),
  	    loop(Parent, Name, NState, CbCache, infinity, HibernateAfterTimeout, Debug1);
  	{ok, {reply, Reply, NState, TimeoutOrHibernate}}
            when ?is_timeout(TimeoutOrHibernate);
                 TimeoutOrHibernate =:= hibernate ->
  	    Debug1 = reply(Name, From, Reply, NState, Debug),
  	    loop(Parent, Name, NState, CbCache, TimeoutOrHibernate, HibernateAfterTimeout, Debug1);
  	{ok, {reply, Reply, NState, {continue, _}=Continue}} ->
  	    Debug1 = reply(Name, From, Reply, NState, Debug),
  	    loop(Parent, Name, NState, CbCache, Continue, HibernateAfterTimeout, Debug1);
  	{ok, {stop, Reason, Reply, NState}} ->
  	    try
              Mod = CbCache#callback_cache.module,
  		terminate(Reason, ?STACKTRACE(), Name, From, Msg, Mod, NState, Debug)
  	    after
  		_ = reply(Name, From, Reply, NState, Debug)
  	    end;
  	Other ->
  	    handle_common_reply(Other, Parent, Name, From, Msg, CbCache, HibernateAfterTimeout, State, Debug)
      end;
  handle_msg(Msg, Parent, Name, State, CbCache, HibernateAfterTimeout, Debug) ->
      Reply = try_dispatch(Msg, CbCache, State),
      handle_common_reply(Reply, Parent, Name, undefined, Msg, CbCache, HibernateAfterTimeout, State, Debug).
  
  handle_common_reply(Reply, Parent, Name, From, Msg, CbCache, HibernateAfterTimeout, State) ->
      Mod = CbCache#callback_cache.module,
      case Reply of
  	{ok, {noreply, NState}} ->
  	    loop(Parent, Name, NState, CbCache, infinity, HibernateAfterTimeout, []);
  	{ok, {noreply, NState, TimeoutOrHibernate}}
            when ?is_timeout(TimeoutOrHibernate);
                 TimeoutOrHibernate =:= hibernate ->
  	    loop(Parent, Name, NState, CbCache, TimeoutOrHibernate, HibernateAfterTimeout, []);
  	{ok, {noreply, NState, {continue, _}=Continue}} ->
  	    loop(Parent, Name, NState, CbCache, Continue, HibernateAfterTimeout, []);
  	{ok, {stop, Reason, NState}} ->
  	    terminate(Reason, ?STACKTRACE(), Name, From, Msg, Mod, NState, []);
  	{'EXIT', Class, Reason, Stacktrace} ->
  