anchor.diff:  %%% Handlers
   %%%----------------------------------------------------------------------
   
  -handler('after', Lid, Context, _Misc) ->
  +handler('after', Lid, #context{actions=Actions}=Context, _Misc) ->
       Action = {'after', Lid},
  -    ?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};
   
   %% Move the process to the blocked set.
   handler(block, Lid,
  -        #context{active = Active, blocked = Blocked} = Context,
  +        #context{active=Active, blocked=Blocked, actions=Actions} = Context,
           _Misc) ->
       Action = {'block', Lid},
  +    NewActions = [Action | Actions],
       ?debug_1(proc_action:to_string(Action) ++ "~n"),
       NewActive = ?SETS:del_element(Lid, Active),
       NewBlocked = ?SETS:add_element(Lid, Blocked),
  -    Context#context{active = NewActive, blocked = NewBlocked, action = Action};
  -
  -handler(demonitor, Lid, Context, _Ref) ->
  +    Context#context{active=NewActive, blocked=NewBlocked, actions=NewActions};
  +
  +handler(demonitor, Lid, #context{actions=Actions}=Context, _Ref) ->
       %% TODO: Get LID from Ref?
       TargetLid = lid:mock(0),
       Action = {demonitor, Lid, TargetLid},
  -    ?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};
   
   %% Remove the exited process from the active set.
   %% NOTE: This is called after a process has exited, not when it calls
   %%       exit/1 or exit/2.
  -handler(exit, Lid, #context{active = Active} = Context,
  +handler(exit, Lid, #context{active = Active, actions = Actions} = Context,
           Reason) ->
       NewActive = ?SETS:del_element(Lid, Active),
       %% Cleanup LID stored info.
  
positive.code: 
  driver(Context, ReplayState) ->
      case state:is_empty(ReplayState) of
          true -> driver_normal(Context, []);
          false -> driver_replay(Context, ReplayState, [])
      end.
  
  driver_replay(Context, ReplayState, Actions) ->
      {Next, Rest} = state:trim_head(ReplayState),
      NewContext = run(Context#context{current = Next, error = ?NO_ERROR}),
      #context{blocked = NewBlocked, action = Action} = NewContext,
      case state:is_empty(Rest) of
          true ->
              case ?SETS:is_element(Next, NewBlocked) of
  
negative.code:     %% Handle and propagate errors.
      case Reason of
          normal ->
              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),
              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{actions = Actions}=Context, Misc) ->
      Action =
          case Misc of
              empty  -> {halt, Lid};
              Status -> {halt, Lid, Status}
          end,
      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},
      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},
      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},
      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},
      NewActions = [Action | Actions],
      ?debug_1(proc_action:to_string(Action) ++ "~n"),
      Context#context{actions = NewActions};
  
  %% Normal receive message handler.
  handler('receive', Lid, #context{actions = Actions}=Context, {From, Msg}) ->
      Action = {'receive', Lid, From, Msg},
      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{actions = Actions}=Context, Msg) ->
      Action = {'receive_no_instr', Lid, Msg},
      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},
      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},
      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, 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, actions = NewActions};
  
  %% FIXME: Refactor this (it's exactly the same as 'spawn')
  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, actions = NewActions};
  
  %% FIXME: Refactor this (it's almost the same as 'spawn')
  handler(spawn_monitor, ParentLid,
          #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, actions = NewActions};
  
  %% Similar to above depending on options.
  handler(spawn_opt, ParentLid,
          #context{active=Active, actions=Actions}=Context, {Ret, Opt}) ->
      {ChildPid, _Ref} =
          case Ret of
              {_C, _R} = CR -> CR;
  