anchor.diff:  %%%===================================================================
   
   %% @private 
  -can_deliver_based_on_trace({Type, Message}, PreviousTrace, BlockedProcesses) ->
  +can_deliver_based_on_trace(Shrinking, {Type, Message}, PreviousTrace, BlockedProcesses) ->
       lager:info("~p: determining if message ~p: ~p can be delivered.", [?MODULE, Type, Message]),
   
  -    [{NextType, NextMessage} | _] = PreviousTrace,
  -
  -    CanDeliver = case {NextType, NextMessage} of 
  -        {Type, Message} ->
  -            lager:info("~p: => YES!", [?MODULE]),
  -            true;
  -        _ ->
  -            lager:info("~p: => NO, waiting for message: ~p: ~p", [?MODULE, NextType, NextMessage]),
  -            false
  -    end,
  -
  -    lager:info("~p: can deliver: ~p blocked processes: ~p", [?MODULE, CanDeliver, BlockedProcesses]),
  -
  -    CanDeliver.
  -
  -%% @private
  -trace_deliver([{_, _} | Trace], BlockedProcesses) ->
  +    case PreviousTrace of 
  +        [{NextType, NextMessage} | _] ->
  +            CanDeliver = case {NextType, NextMessage} of 
  +                {Type, Message} ->
  +                    lager:info("~p: => YES!", [?MODULE]),
  +                    true;
  +                _ ->
  +                    %% But, does the message actually exist in the trace?
  +                    case lists:member({Type, Message}, PreviousTrace) of 
  +                        true ->
  +                            lager:info("~p: => NO, waiting for message: ~p: ~p", [?MODULE, NextType, NextMessage]),
  +                            false;
  +                        false ->
  +                            %% new messages in the middle of the trace.
  +                            %% this *should* be the common case if we shrink from the start of the trace forward (foldl)
  +                            case Shrinking of 
  +                                true ->
  +                                    lager:info("~p: => CONDITIONAL YES, message doesn't exist in previous trace, but shrinking: ~p ~p", [?MODULE, Type, Message]),
  +                                    true;
  +                                false ->
  +                                    lager:info("~p: => NO, waiting for message: ~p: ~p", [?MODULE, NextType, NextMessage]),
  +                                    false
  +                            end
  +                    end
  +            end,
  +
  +            lager:info("~p: can deliver: ~p blocked processes: ~p", [?MODULE, CanDeliver, BlockedProcesses]),
  +
  +            CanDeliver;
  +        [] ->
  +            %% end of trace, but we are still receiving messages. 
  +            %% this *should* be the common case if we shrink from the back of the trace forward (foldr)
  +            case Shrinking of 
  +                true ->
  +                    lager:info("~p: => CONDITIONAL YES, message doesn't exist in previous trace, but shrinking: ~p ~p", [?MODULE, Type, Message]),
  +                    true;
  +                false ->
  +                    lager:info("~p: => message should not have been delivered, blocking.", [?MODULE]),
  +                    false
  +            end
  +    end.
  +
  +%% @private
  +trace_deliver(Shrinking, {Type, Message}, [{Type, Message} | Trace], BlockedProcesses) ->
       lager:info("~p: delivering single message!", [?MODULE]),
   
       %% Advance the trace, then try to flush the blocked processes.
  -    trace_deliver_log_flush(Trace, BlockedProcesses).
  -
  -%% @private
  -trace_deliver_log_flush(Trace0, BlockedProcesses0) ->
  +    trace_deliver_log_flush(Shrinking, Trace, BlockedProcesses);
  +trace_deliver(_Shrinking, {_, _}, [{_, _} | Trace], BlockedProcesses) ->
  +    lager:info("~p: delivering single message (not in the trace)!", [?MODULE]),
  +
  +    %% Advance the trace, don't flush blocked processes, since we weren't in the trace, nothing is blocked.
  +    {Trace, BlockedProcesses};
  +trace_deliver(_Shrinking, {_, _}, [], BlockedProcesses) ->
  +    lager:info("~p: delivering single message (not in the trace -- end of trace)!", [?MODULE]),
  +
  +    %% No trace to advance.
  +    {[], BlockedProcesses}.
  +
  +%% @private
  +trace_deliver_log_flush(Shrinking, Trace0, BlockedProcesses0) ->
       lager:info("~p: attempting to flush blocked messages!", [?MODULE]),
   
       %% Iterate blocked processes in an attempt to remove one.
       {ND, T, BP} = lists:foldl(fun({{NextType, NextMessage}, Pid} = BP, {NumDelivered1, Trace1, BlockedProcesses1}) ->
  -        case can_deliver_based_on_trace({NextType, NextMessage}, Trace1, BlockedProcesses0) of 
  +        case can_deliver_based_on_trace(Shrinking, {NextType, NextMessage}, Trace1, BlockedProcesses0) of 
               true ->
                   lager:info("~p: pid ~p can be unblocked!", [?MODULE, Pid]),
   
  
positive.code: -record(state, {previous_trace=[],
                  trace=[], 
                  replay=false,
                  blocked_processes=[],
                  identifier=undefined}).
  
  
negative.code:     case ND > 0 of 
          true ->
              lager:info("~p: was able to deliver a message, trying again", [?MODULE]),
              trace_deliver_log_flush(Shrinking, T, BP);
          false ->
              lager:info("~p: flush attempt finished.", [?MODULE]),
              {T, BP}
  