anchor.diff:      case event_type(Type) of
           true when StateCall ->
               NextEvent = {Type,Content},
  -            case Debug of
  -                ?not_sys_debug ->
  +            if
  +                Debug =:= ?not_sys_debug ->
                       loop_actions_list(
                         P, Debug, S, Q, NextState_NewData,
                         [NextEvent|NextEventsR],
                         Hibernate, TimeoutsR, Postpone,
                         CallEnter, StateCall, Actions);
  -                _ ->
  +                true ->
                       Name = P#params.name,
                       {NextState,_NewData} = NextState_NewData,
  -                    Debug_1 =
  -                        sys_debug(
  -                          Debug, Name, {in,{Type,Content},NextState}),
  +                    Debug_1 = sys_debug(Debug, Name, {in,NextEvent,NextState}),
                       loop_actions_list(
                         P, Debug_1, S, Q, NextState_NewData,
                         [NextEvent|NextEventsR],
                         Hibernate, TimeoutsR, Postpone,
                         CallEnter, StateCall, Actions)
  -              end;
  +            end;
           _ ->
  -            terminate(
  -              error,
  -              {if
  -                   StateCall ->
  -                       bad_action_from_state_function;
  -                   true ->
  -                       bad_state_enter_action_from_state_function
  -               end,
  -               {next_event,Type,Content}},
  -              ?STACKTRACE(), P, Debug,
  -              S#state{
  -                state_data = NextState_NewData,
  -                hibernate = Hibernate},
  -              Q)
  -    end.
  +            loop_actions_next_event_bad(
  +              P, Debug, S, Q, NextState_NewData,
  +              StateCall, Hibernate, Type, Content)
  +    end.
  +
  +loop_actions_next_event_bad(
  +  P, Debug, S, Q, NextState_NewData,
  +  StateCall, Hibernate, Type, Content) ->
  +    terminate(
  +      error,
  +      {case StateCall of
  +           true ->
  +               bad_action_from_state_function;
  +           false ->
  +               bad_state_enter_action_from_state_function
  +       end,
  +       {next_event,Type,Content}},
  +      ?STACKTRACE(), P, Debug,
  +      S#state{
  +        state_data = NextState_NewData,
  +        hibernate = Hibernate},
  +      Q).
   
   %% Do the state transition
   %%
  
positive.code:       CallEnter, StateCall, listify(Actions)).
  %%
  %% Shortcut for no actions
  -compile({inline, [loop_actions/10]}).
  loop_actions(
    P, Debug, S, Q, NextState_NewData,
    NextEventsR, Hibernate, TimeoutsR, Postpone,
  
negative.code:     %% and immediately was awakened.
      %%
      _ = garbage_collect(),
      %%
      %% The field 'hibernate' in S is now invalid and will be
      %% restored when looping back to loop/3 or loop_event/5.
      %%
      Q = [Event|Events],
      loop_state_callback(P, Debug, S, Q, S#state.state_data, Event);
  loop_event(P, Debug, S, Event, Events) ->
      %%
      %% The field 'hibernate' in S is now invalid and will be
      %% restored when looping back to loop/3 or loop_event/5.
      %%
      Q = [Event|Events],
      loop_state_callback(P, Debug, S, Q, S#state.state_data, Event).
  
  %% Make a state enter call to the state function, we loop back here
  %% from further down if state enter calls are enabled
  %%
  -compile({inline, [loop_state_enter/9]}).
  loop_state_enter(
    P, Debug, #state{state_data = {PrevState,_PrevData}} = S,
    Q, NextState_NewData,
  