anchor.diff:  handle_request_for_more(ClientId,FromSeq,WSize,S = #state{live_subs = Subs,
                                                             queue = SQ}) ->
       S1 = case dict:find(ClientId,Subs) of
  -        {ok,Sub = #sub{pid = Pid}} ->
  -            MaxSeq = shared_queue:max_seq(SQ),
  -            {ok,{From,To},Sub1} = packet_range_to_send(MaxSeq,FromSeq,WSize,Sub),
  -            Packets = shared_queue:read(From,To,SQ),
  -            S2 = S#state{live_subs = dict:update(ClientId,Sub1,Subs)},
  -            send_packets_to_client(Pid,Packets,S2),
  -            S2;
  -        error ->
  -            S
  -     end,
  +            {ok,Sub = #sub{pid = Pid}} ->
  +                MaxSeq = shared_queue:max_seq(SQ),
  +                {ok,{From,To},Sub1} = packet_range_to_send(MaxSeq,FromSeq,WSize,Sub),
  +                Packets = shared_queue:read(From,To,SQ),
  +                S2 = S#state{live_subs = dict:update(ClientId,Sub1,Subs)},
  +                send_packets_to_client(Pid,Packets,S2),
  +                S2;
  +            error ->
  +                S
  +        end,
       {ok,{reply,ok},S1}.
   
   handle_ack(ClientId,AckSeq,S = #state{queue = SQ,garbage = Garbage}) ->
  
positive.code: %%
  
  handle_new_packet(Packet,QoS,_From,S = #state{live_subs = Subs,
                                                queue = SQ}) ->
  
      SQ1 = shared_queue:pushr({QoS,Packet},SQ),
  
negative.code:         error -> S
      end.
  
  maybe_store_retained(#packet{retain = false},Ret)                -> Ret;
  maybe_store_retained(#packet{topic = Topic, content = <<>>},Ret) -> dict:erase(Topic,Ret);
  maybe_store_retained(Packet = #packet{topic = Topic},Ret)        -> dict:store(Topic,Packet,Ret).
  
  recover(SubRecord,S) ->
      lists:foldl(fun recover_sub/2,S,SubRecord).
  
  