anchor.diff:      %% Handle and propagate errors.
       case Reason of
           normal ->
  -            Action = {exit, Lid, normal},
  -            ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -            Context#context{active = NewActive, action = Action};
  +            Action1 = {exit, Lid, normal},
  +            NewActions1 = [Action1 | Actions],
  +            ?debug_1(proc_action:to_string(Action1) ++ "~n"),
  +            Context#context{active = NewActive, actions = NewActions1};
           _Else ->
               Error = error:new(Reason),
  -            Action = {exit, Lid, error:type(Error)},
  -            ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -            Context#context{active = NewActive, error = Error, action = Action}
  +            Action2 = {exit, Lid, error:type(Error)},
  +            NewActions2 = [Action2 | Actions],
  +            ?debug_1(proc_action:to_string(Action2) ++ "~n"),
  +            Context#context{active=NewActive, error=Error, actions=NewActions2}
       end;
   
   %% Return empty active and blocked queues to force run termination.
  -handler(halt, Lid, Context, Misc) ->
  +handler(halt, Lid, #context{actions = Actions}=Context, Misc) ->
       Action =
           case Misc of
  -            empty -> {halt, Lid};
  +            empty  -> {halt, Lid};
               Status -> {halt, Lid, Status}
           end,
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{active=?SETS:new(), blocked=?SETS:new(), action=Action};
  -
  -handler(is_process_alive, Lid, Context, TargetPid) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{active=?SETS:new(),blocked=?SETS:new(),actions=NewActions};
  +
  +handler(is_process_alive, Lid, #context{actions=Actions}=Context, TargetPid) ->
       TargetLid = lid:from_pid(TargetPid),
       Action = {is_process_alive, Lid, TargetLid},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  -
  -handler(link, Lid, Context, TargetPid) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
  +
  +handler(link, Lid, #context{actions = Actions}=Context, TargetPid) ->
       TargetLid = lid:from_pid(TargetPid),
       Action = {link, Lid, TargetLid},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  -
  -handler(monitor, Lid, Context, {Item, _Ref}) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
  +
  +handler(monitor, Lid, #context{actions = Actions}=Context, {Item, _Ref}) ->
       TargetLid = lid:from_pid(Item),
       Action = {monitor, Lid, TargetLid},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  -
  -handler(process_flag, Lid, Context, {Flag, Value}) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
  +
  +handler(process_flag, Lid, #context{actions=Actions}=Context, {Flag, Value}) ->
       Action = {process_flag, Lid, Flag, Value},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
   
   %% Normal receive message handler.
  -handler('receive', Lid, Context, {From, Msg}) ->
  +handler('receive', Lid, #context{actions = Actions}=Context, {From, Msg}) ->
       Action = {'receive', Lid, From, Msg},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
   
   %% Receive message handler for special messages, like 'EXIT' and 'DOWN',
   %% which don't have an associated sender process.
  -handler('receive_no_instr', Lid, Context, Msg) ->
  +handler('receive_no_instr', Lid, #context{actions = Actions}=Context, Msg) ->
       Action = {'receive_no_instr', Lid, Msg},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  -
  -handler(register, Lid, Context, {RegName, RegLid}) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
  +
  +handler(register, Lid, #context{actions=Actions}=Context, {RegName, RegLid}) ->
       Action = {register, Lid, RegName, RegLid},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  -
  -handler(send, Lid, Context, {DstPid, Msg}) ->
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
  +
  +handler(send, Lid, #context{actions = Actions}=Context, {DstPid, Msg}) ->
       DstLid = lid:from_pid(DstPid),
       Action = {send, Lid, DstLid, Msg},
  -    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  -    Context#context{action = Action};
  +    NewActions = [Action | Actions],
  +    ?debug_1(proc_action:to_string(Action) ++ "~n"),
  +    Context#context{actions = NewActions};
   
   %% Link the newly spawned process to the scheduler process and add it to the
   %% active set.
  -handler(spawn, ParentLid, #context{active = Active} = Context, ChildPid) ->
  +handler(spawn, ParentLid,
  +        #context{active= Active, actions = Actions} = Context, ChildPid) ->
       link(ChildPid),
       ChildLid = lid:new(ChildPid, ParentLid),
       Action = {spawn, ParentLid, ChildLid},
  +    NewActions = [Action | Actions],
       ?debug_1(proc_action:to_string(Action) ++ "~n"),
       NewActive = ?SETS:add_element(ChildLid, Active),
  -    Context#context{active = NewActive, action = Action};
  +    Context#context{active = NewActive, actions = NewActions};
   
   %% FIXME: Refactor this (it's exactly the same as 'spawn')
  -handler(spawn_link, ParentLid, #context{active = Active} = Context, ChildPid) ->
  +handler(spawn_link, ParentLid,
  +        #context{active = Active, actions = Actions} = Context, ChildPid) ->
       link(ChildPid),
       ChildLid = lid:new(ChildPid, ParentLid),
       Action = {spawn_link, ParentLid, ChildLid},
  +    NewActions = [Action | Actions],
       ?debug_1(proc_action:to_string(Action) ++ "~n"),
       NewActive = ?SETS:add_element(ChildLid, Active),
  -    Context#context{active = NewActive, action = Action};
  +    Context#context{active = NewActive, actions = NewActions};
   
   %% FIXME: Refactor this (it's almost the same as 'spawn')
   handler(spawn_monitor, ParentLid,
  -        #context{active = Active} = Context, {ChildPid, _Ref}) ->
  +        #context{active=Active, actions=Actions}=Context, {ChildPid, _Ref}) ->
       link(ChildPid),
       ChildLid = lid:new(ChildPid, ParentLid),
       Action = {spawn_monitor, ParentLid, ChildLid},
  +    NewActions = [Action | Actions],
       ?debug_1(proc_action:to_string(Action) ++ "~n"),
       NewActive = ?SETS:add_element(ChildLid, Active),
  -    Context#context{active = NewActive, action = Action};
  +    Context#context{active = NewActive, actions = NewActions};
   
   %% Similar to above depending on options.
   handler(spawn_opt, ParentLid,
  -        #context{active = Active} = Context, {Ret, Opt}) ->
  +        #context{active=Active, actions=Actions}=Context, {Ret, Opt}) ->
       {ChildPid, _Ref} =
           case Ret of
               {_C, _R} = CR -> CR;
  
positive.code: %%   Terminate the run without errors.
  %% - There exists at least one active process =>
  %%   Continue run.
  check_for_errors(#context{error=NewError, action=Action, active=NewActive,
                            blocked=NewBlocked} = NewContext, Actions) ->
      NewActions = [Action | Actions],
      case NewError of
          ?NO_ERROR ->
              case ?SETS:size(NewActive) of
  
negative.code: 
  driver(Context, ReplayState) ->
      case state:is_empty(ReplayState) of
          true -> driver_normal(Context);
          false -> driver_replay(Context, ReplayState)
      end.
  
  driver_replay(Context, ReplayState) ->
      {Next, Rest} = state:trim_head(ReplayState),
      NewContext = run(Context#context{current = Next, error = ?NO_ERROR}),
      #context{blocked = NewBlocked} = NewContext,
      case state:is_empty(Rest) of
          true ->
              case ?SETS:is_element(Next, NewBlocked) of
  