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: reply(Name, From, Reply, State, Debug) ->
      reply(From, Reply),
      sys:handle_debug(Debug, fun print_event/3, Name,
  		     {out, Reply, From, State} ).
  
  
  %%-----------------------------------------------------------------
  %% Callback functions for system messages handling.
  %%-----------------------------------------------------------------
  system_continue(Parent, Debug, [Name, State, Mod, Time, HibernateAfterTimeout]) ->
      loop(Parent, Name, State, Mod, Time, HibernateAfterTimeout, Debug).
  
  -spec system_terminate(_, _, _, [_]) -> no_return().
  
  system_terminate(Reason, _Parent, Debug, [Name, State, Mod, _Time, _HibernateAfterTimeout]) ->
      terminate(Reason, ?STACKTRACE(), Name, undefined, [], Mod, State, Debug).
  
  system_code_change([Name, State, Mod, Time, HibernateAfterTimeout], _Module, OldVsn, Extra) ->
      case catch Mod:code_change(OldVsn, State, Extra) of
  	{ok, NewState} -> {ok, [Name, NewState, Mod, Time, HibernateAfterTimeout]};
  	Else -> Else
      end.
  
  system_get_state([_Name, State, _Mod, _Time, _HibernateAfterTimeout]) ->
      {ok, State}.
  
  system_replace_state(StateFun, [Name, State, Mod, Time, HibernateAfterTimeout]) ->
      NState = StateFun(State),
      {ok, NState, [Name, NState, Mod, Time, HibernateAfterTimeout]}.
  
  %%-----------------------------------------------------------------
  %% Format debug messages.  Print them as the call-back module sees
  
negative.code: 	( (X) =:= infinity orelse ( is_integer(X) andalso (X) >= 0 ) )
  ).
  
  -record(callback_cache,{module :: module(),
                          handle_call :: fun((Request :: term(), From :: from(), State :: term()) ->
                              {reply, Reply :: term(), NewState :: term()} |
                              {reply, Reply :: term(), NewState :: term(), timeout() | hibernate | {continue, term()}} |
                              {noreply, NewState :: term()} |
                              {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
                              {stop, Reason :: term(), Reply :: term(), NewState :: term()} |
                              {stop, Reason :: term(), NewState :: term()}),
                          handle_cast :: fun((Request :: term(), State :: term()) ->
                              {noreply, NewState :: term()} |
                              {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
                              {stop, Reason :: term(), NewState :: term()}),
                          handle_info :: fun((Info :: timeout | term(), State :: term()) ->
                              {noreply, NewState :: term()} |
                              {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
                              {stop, Reason :: term(), NewState :: term()})}).
  %%%=========================================================================
  %%%  API
  %%%=========================================================================
  