anchor.diff:      monref_idx  ::any()  %% dictionary of (MonitorRef,ClientId}
   }).
   
  --record(client_reg, {
  -    qos         ::qos(),
  -    monref      ::any(),
  -    pid         ::pid(),
  -    seq         ::non_neg_integer()
  +-record(client_sub, {
  +    qos         ::qos(), %% QoS for this client subscription
  +    monref      ::any(), %% monitor reference for the process handling the client
  +    pid         ::pid(), %% Process id of the process handling the client
  +    client_seq  ::non_neg_integer() %% the version number of the client process registration
  +                                    %% (incremented every time a new client process is spawned)
   }).
   
   %%%===================================================================
  
positive.code:             {reply,ok,S};
          {ok,ExistingReg} ->
              case ExistingReg of
                 #client_reg{monref = MonRef, seq = Seq} when NewSeq >= Seq ->
                     mqtt_sub_repo:remove_sub(S#state.filter,ClientId),
                     Mon1 = maybe_demonitor_reg(MonRef,Mon),
                     Clients1 = orddict:erase(ClientId,Clients),
                     S1 = S#state{monref_idx = Mon1,clients = Clients1},
                     case orddict:size(Clients1) of
                         0 -> {reply,ok,S1}; %% {stop,no_clients,ok,NewState};
                         _ -> {reply,ok,S1}
                     end;
                  _ ->
  
negative.code: set_sub(S = #state{monref_idx = Mon,clients = Clients},{ClientId,NewQoS,NewSeq,NewPid}) ->
      MonRef = monitor(process,NewPid),
      Mon1 = orddict:store(MonRef,ClientId,Mon),
      NewReg = #client_sub{client_seq = NewSeq,
                           qos = NewQoS,
                           pid = NewPid,
                           monref = MonRef},
  