anchor.diff:  handle_new_packet(Packet,QoS,_From,S = #state{live_subs = Subs,
                                                 queue = SQ}) ->
   
  -    SQ1 = shared_queue:pushr(Packet,SQ),
  +    SQ1 = shared_queue:pushr({QoS,Packet},SQ),
       Max = shared_queue:max_seq(SQ1),
       {PushTo,Subs1} = dict:fold(fun(ClientId,Sub,AccIn = {PushToAcc,SubsAcc}) ->
                                       case maybe_update_waiting_sub(Max,Sub) of
  
positive.code:                 live_subs = dict:new(),
                  dead_subs = dict:new(),
                  packet_seq = Seq,
                  min_acks = min_val_tree:new(),
                  queue = shared_queue:new(Seq),
                  repo = Repo}}.
  
  
negative.code:             end
      end;
  
  handle_call({unsub,ClientId,Seq}, _From, S = #state{live_subs = Subs,
                                                      queue = SQ,
                                                      garbage = Garbage}) ->
      case dict:find(ClientId,Subs) of
          error ->
              {reply,ok,S};
          {ok, Reg} ->
              case Reg of
                  #sub{monref = MonRef,client_seq = OldSeq} when Seq >= OldSeq ->
                      mqtt_sub_repo:remove_sub(S#state.filter,ClientId),
                      #state{monref_idx = Mon} = S,
                      Mon1 = maybe_demonitor_reg(MonRef,Mon),
                      Subs1 = dict:erase(ClientId,Subs),
                      {MoreGarbage,SQ1} = shared_queue:remove(ClientId,SQ),
                      S1 = S#state{monref_idx = Mon1,
                                   live_subs = Subs1,
                                   queue = SQ1,
                                   garbage = ?MONOID:as(Garbage,MoreGarbage)},
                      case dict:size(Subs1) of
                          0 -> {stop, no_subs,ok,S1};
                          _ -> {reply,ok,S1}
  