anchor.diff:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   %% @private
  -clean_state() ->
  -  clean_state(queue:new()).
  -
  -%% @private
  --spec clean_state(map()) -> map();
  -                 (queue:queue()) -> map().
  +clean_state() -> clean_state(queue:new()).
  +
  +%% @private
  +-spec clean_state(map()) -> map(); (queue:queue()) -> map().
   clean_state(State) when is_map(State) ->
  -  clean_state(get_pending_reqs(State));
  -
  -%% @private
  +    clean_state(get_pending_reqs(State));
   clean_state(Reqs) ->
       #{
          pid => undefined,
  
positive.code: %% @private
  -spec receive_data(term(), pid(), term()) -> term().
  receive_data(Event, From, State) ->
    enqueue_work_or_stop(receive_data, Event, From, State).
  
  %% @private
  %% @doc Regular response
  
negative.code: 
  %% @private
  enqueue_work_or_stop(FSM = at_rest, Event, From, State) ->
      enqueue_work_or_stop(FSM, Event, From, State, 0);
  enqueue_work_or_stop(FSM, Event, From, State) ->
      enqueue_work_or_stop(FSM, Event, From, State, infinity).
  
  %% @private
  enqueue_work_or_stop(FSM, Event, From, State, Timeout) ->
      case create_work(Event, From) of
          {ok, Work} ->
              NewState = append_work(Work, State),
              {next_state, FSM, NewState, Timeout};
          not_work ->
              {stop, {unexpected, Event}, State}
      end.
  
  %% @private
  create_work({M = get_async, {HandleEvent, AsyncMode}, Args}, From) ->
      {ok, {M, {HandleEvent, AsyncMode}, Args, From}};
  create_work({M, Args}, From)
    when M == get orelse M == post
         orelse M == delete orelse M == head
         orelse M == options orelse M == patch
         orelse M == put ->
      {ok, {M, Args, From}};
  create_work(_, _) ->
      not_work.
  
  %% @private
  get_work(State) ->
      PendingReqs = maps:get(pending_requests, State),
      case queue:is_empty(PendingReqs) of
          true ->
              no_work;
          false ->
              {{value, Work}, Rest} = queue:out(PendingReqs),
              NewState = State#{pending_requests => Rest},
              {ok, Work, NewState}
      end.
  
  %% @private
  append_work(Work, State) ->
      PendingReqs = get_pending_reqs(State),
      NewPending = queue:in(Work, PendingReqs),
      maps:put(pending_requests, NewPending, State).
  
  %% @private
  get_pending_reqs(State) ->
      maps:get(pending_requests, State).
  