anchor.diff:      terminate(Reason, Name, [], Mod, State, Debug).
   
   system_code_change([Name, State, Mod, Time], _Module, OldVsn, Extra) ->
  -    case catch Mod:code_change(OldVsn, State, Extra) of
  -	{ok, NewState} -> {ok, [Name, NewState, Mod, Time]};
  -	Else -> Else
  -    end.
  -
  -system_get_state([_Name, State, _Mod, _Time]) ->
  +    case catch Mod:code_change(OldVsn, State, Extra) of         %% TODO State needs working on
  +        {ok, NewState} -> {ok, [Name, NewState, Mod, Time]}
  +    ;   Else -> Else
  +    end.
  +
  +system_get_state([_Name, State, _Mod, _Time]) ->        %% TODO State needs working on
       {ok, State}.
   
   system_replace_state(StateFun, [Name, State, Mod, Time]) ->
  -    NState = StateFun(State),
  +    NState = StateFun(State),                           %% TODO State needs working on
       {ok, NState, [Name, NState, Mod, Time]}.
   
   %%-----------------------------------------------------------------
  
positive.code: %%-----------------------------------------------------------------
  print_event(Dev, {in, Msg}, Name) ->
      case Msg of
  	{'$gen_call', {From, _Tag}, Call} ->
  	    io:format(Dev, "*DBG* ~p got call ~p from ~w~n",
  		      [Name, Call, From]);
  	{'$gen_cast', Cast} ->
  	    io:format(Dev, "*DBG* ~p got cast ~p~n",
  		      [Name, Cast]);
  	_ ->
  	    io:format(Dev, "*DBG* ~p got ~p~n", [Name, Msg])
      end;
  print_event(Dev, {out, Msg, To, State}, Name) ->
      io:format(Dev, "*DBG* ~p sent ~p to ~w, new state ~w~n", 
  	      [Name, Msg, To, State]);
  print_event(Dev, {noreply, State}, Name) ->
      io:format(Dev, "*DBG* ~p new state ~w~n", [Name, State]);
  print_event(Dev, Event, Name) ->
  
negative.code: 
  terminate(Reason, Name, Msg, Mod, State, Debug) ->
      case catch Mod:terminate(Reason, State) of
      {'EXIT', R} ->
          error_info(R, Name, Msg, State, Debug),
          exit(R);
      _ ->
          case Reason of
          normal ->
              exit(normal);
          shutdown ->
              exit(shutdown);
          {shutdown,_}=Shutdown ->
              exit(Shutdown);
          _ ->
              FmtState =
              case erlang:function_exported(Mod, format_status, 2) of
                  true ->
                  Args = [get(), State],
                  case catch Mod:format_status(terminate, Args) of
                      {'EXIT', _} -> State;
                      Else -> Else
                  end;
                  _ ->
                  State
              end,
              error_info(Reason, Name, Msg, FmtState, Debug),
              exit(Reason)
          end
      end.
  
  error_info(_Reason, application_controller, _Msg, _State, _Debug) ->
  