anchor.diff:      S1 = S#state{live_subs = Subs1,
                    queue = SQ1,
                    retained = Ret1},
  -    lists:foreach(fun({Pid,Ps}) -> send_packets_to_client(Pid,Filter,Ps) end,SendTo),
  +    send_packets_to_clients(Filter,SendTo),
       {reply,{ok,NewSeq},S1}.
   
   update_waiting_subs(Q) ->
  -    fun(ClientId,Sub,AccIn = {SendToAcc,SubsAcc}) ->
  -        {Pid,Packets,Sub1} = mqtt_sub_state:maybe_take(Q,Sub),
  +    fun(ClientId,{Pid,Sub},AccIn = {SendToAcc,SubsAcc}) ->
  +        {Packets,Sub1} = mqtt_sub_state:take_any(Q,Sub),
           case Packets of
               [] ->  AccIn;
  -            _ -> {[{Pid,Packets}|SendToAcc],dict:store(ClientId,Sub1,SubsAcc)}
  +            _ ->
  +                SubsAcc1 = dict:store(ClientId,{Pid,Sub1},SubsAcc),
  +                SendToAcc1 = [{Pid,Packets}|SendToAcc],
  +                {SendToAcc1,SubsAcc1}
           end
       end.
   
  
positive.code:     case dict:find(ClientId,Subs) of
          error ->
              {reply,ok,S};
          {ok,Sub} ->
              case mqtt_sub_state:is_old(CSeq,Sub) of
                  true ->
                      {reply,ok,S};
  
negative.code:                                       live_subs = Subs,
                                        queue = SQ}) ->
      case dict:find(ClientId,Subs) of
          {ok,{Pid,Sub}} ->
              {Packets,Sub1} = mqtt_sub_state:take(WSize,SQ,Sub),
              S1 = S#state{live_subs = dict:store(ClientId,{Pid,Sub1},Subs)},
              send_packets_to_client(Pid,Filter,Packets),
              S1;
          error -> S
      end.
  
  