anchor.diff:                                                    MsgStoreRef, true),
                         Acc
                 end, [], WAcks).
  +
  +handle_waiting_msgs(#state{waiting_msgs=[]} = State) -> State;
  +handle_waiting_msgs(#state{waiting_msgs=Msgs, queue_pid=QPid} = State) ->
  +    case handle_messages(Msgs, [], State, []) of
  +        {NewState, []} ->
  +            %% we're ready to take more
  +            vmq_queue:notify(QPid),
  +            NewState#state{waiting_msgs=[]};
  +        {NewState, Waiting} ->
  +            %% TODO: since we don't notfiy the queue it is now possible
  +            %% that ALSO QoS0 messages are getting queued up, and need
  +            %% to wait until check_in_flight(_) returns true again.
  +            %% That's unfortunate, but would need a different implementation
  +            %% of the vmq_queue FSM which differentiates between QoS.
  +            NewState#state{waiting_msgs=Waiting}
  +    end.
  +
  +
   
   -spec send_after(non_neg_integer(), any()) -> reference().
   send_after(Time, Msg) ->
  
positive.code:         false ->
              State
      end,
      NewState1 = handle_messages(Msgs, [], NewState),
      vmq_queue:notify(QPid),
      {next_state, StateName, maybe_trigger_counter_update(NewState1)};
  handle_info(Info, _StateName, State) ->
      {stop, {error, {unknown_info, Info}}, State} .
  
  
negative.code:     case dict:find(MessageId, WAcks) of
          {ok, {_, _, Ref, undefined}} ->
              cancel_timer(Ref), % cancel rpubrel timer
              {connected,
               handle_waiting_msgs(State#state{
                                     waiting_acks=dict:erase(MessageId, WAcks)})};
          _ -> % error or wrong waiting_ack, definitely not well behaving client
              lager:debug("stopped connected session, due to qos2 pubrel missing ~p", [MessageId]),
              {stop, normal, State}
  