anchor.diff:                  case Flavor =:= 'none' of
                       true -> [];
                       false ->
  +                        Awakened = ordsets:subtract(
  +                                     NewSleepSetCandidates, NewSleepSet),
                           RestError = ordsets:del_element(Lid, OldErrorNxt),
                           ordsets:union(Awakened, RestError)
                   end
           end,
  +    NewLastBlocked = ordsets:is_element(Lid, NewBlocked),    
  +    [NewTraceTop#trace_state{
  +       last_blocked = NewLastBlocked,
  +       error_nxt = NewErrorNext,
  +       sleep_set = NewSleepSet}|
  +     PrevTrace].
  +
  +replay_update_trace(#trace_state{last = {Lid, _, _} = Selected} = ReplayTop,
  +                    Trace) ->
  +    CommonNewTraceTop = ReplayTop#trace_state{last = Selected},
  +    NewTraceTop = update_instr_info(Lid, Selected, CommonNewTraceTop),
  +    PossiblyRewrittenSelected = NewTraceTop#trace_state.last,
       PrevTrace =
           case PossiblyRewrittenSelected =:= Selected of
  -            true -> [PrevTraceTop|Rest];
  -            false -> rewrite_while_awaked(PossiblyRewrittenSelected,
  -                                          Selected,
  -                                          [PrevTraceTop|Rest])
  -        end,
  -    NewTrace =
  -        [NewTraceTop#trace_state{
  -           last = PossiblyRewrittenSelected,
  -           lid_trace = NewLidTrace,
  -           error_nxt = NewErrorNext,
  -           sleep_set = NewSleepSet}|
  -         PrevTrace],
  -    State#dpor_state{trace = NewTrace}.
  +            true -> Trace;
  +            false ->
  +                rewrite_while_awaked(PossiblyRewrittenSelected, Selected, Trace)
  +        end,
  +    [NewTraceTop|PrevTrace].
   
   recent_dependency_cv({_Lid, {ets, _Info}, _} = Transition,
  -                     ClockVector, LidTrace) ->
  +                     ClockVector, Trace) ->
       Fun =
  -        fun({Queue, CVAcc}) ->
  -            {Ret, NewQueue} = queue:out_r(Queue),
  -            case Ret of
  -                empty -> {done, CVAcc};
  -                {value, {Transition2, CV}} ->
  -                    case concuerror_deps:dependent(Transition, Transition2) of
  -                        true -> {cont, {NewQueue, max_cv(CVAcc, CV)}};
  -                        false -> {cont, {NewQueue, CVAcc}}
  -                    end
  -            end
  -        end,
  -    dynamic_loop_acc(Fun, {LidTrace, ClockVector});
  +        fun(#trace_state{
  +            last = {Lid, _, _} = Transition2,
  +            clock_map = CM}, CVAcc) ->
  +                case concuerror_deps:dependent(Transition, Transition2) of
  +                    true ->
  +                        CV = lookup_clock(Lid, CM),
  +                        max_cv(CVAcc, CV);
  +                    false -> CVAcc
  +                end
  +        end,
  +    lists:foldl(Fun, ClockVector, Trace);
   recent_dependency_cv(_Transition, ClockVector, _Trace) ->
       ClockVector.
  -
  -dynamic_loop_acc(Fun, Arg) ->
  -    case Fun(Arg) of
  -        {done, Ret} -> Ret;
  -        {cont, NewArg} -> dynamic_loop_acc(Fun, NewArg)
  -    end.
   
   update_lid_enabled(Lid, {_, Next, _}, Pollable, Enabled, Blocked) ->
       {NewEnabled, NewBlocked} =
  
positive.code:     State#dpor_state{trace = [NewTraceTop|Rest]}.
  
  report_error(Transition, State) ->
      #dpor_state{trace = [TraceTop|_], tickets = Tickets} = State,
      ?debug("ERROR!\n~P\n",[Transition, ?DEBUG_DEPTH]),
      Error = convert_error_info(Transition),
      LidTrace = queue:in({Transition, foo}, TraceTop#trace_state.lid_trace),
      Ticket = create_ticket(Error, LidTrace),
      %% Report the error to the progress logger.
      concuerror_log:progress({'error', Ticket}),
      State#dpor_state{must_replay = true, tickets = [Ticket|Tickets]}.
  
  create_ticket(Error, LidTrace) ->
      InitTr = init_tr(),
      [{P1, init, []} = InitTr|Trace] = [S || {S,_V} <- queue:to_list(LidTrace)],
      InitSet = sets:add_element(P1, sets:new()),
      {ErrorState, _Procs} =
          lists:mapfoldl(fun convert_error_trace/2, InitSet, Trace),
  
negative.code:                      enabled = NewEnabled, blocked = NewBlocked,
                       clock_map = NewClockMap, sleep_set = NewSleepSetCandidates,
                       pollable = NewPollable, preemptions = NewPreemptions},
      InstrNewTraceTop = update_instr_info(Lid, Selected, CommonNewTraceTop),
      NewTraceTop = check_pollable(InstrNewTraceTop),
      PossiblyRewrittenSelected = NewTraceTop#trace_state.last,
      ?debug("Selected: ~P\n",[PossiblyRewrittenSelected, ?DEBUG_DEPTH]),
      Expected = dict:fetch(Lid, Nexts),
      PrevTrace =
          case PossiblyRewrittenSelected =:= Expected of
              true -> Trace;
              false ->
                  rewrite_while_awaked(PossiblyRewrittenSelected, Selected, Trace)
          end,
      NewSleepSet =
          case Flavor =:= 'none' of
              true -> [];
  