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: handle_call(get_live_clients, _From, S = #state{clients = Clients}) ->
      ClientPids = [
          {ClientId,QoS,Pid} ||
          {ClientId,#client_reg{pid = Pid,qos = QoS}} <- orddict:to_list(Clients), Pid =/= undefined],
      {reply, ClientPids, S};
  
  handle_call(_Request, _From, State) ->
  
negative.code:             {reply,ok,S1};
          {ok,CurReg} ->
              case CurReg of
                  #client_sub{pid = OldPid, client_seq = CurSeq} when CurSeq > NewSeq ->
                      if OldPid =:= NewPid; OldPid =:= undefined ->
                              {reply,ok,S}; %%ignore old messages from this Pid
                          true ->
                              {reply,duplicate,S} %% this is an old process
                      end;
                  #client_sub{pid = NewPid,qos = NewQoS} ->
                      {reply,ok,S}; %% nothing to change
                  #client_sub{pid = NewPid} ->
                      mqtt_sub_repo:save_sub(Filter,NewSub),
                      %% replace existing QoS and Seq
                      S1 = S#state{clients = orddict:store(
                          ClientId,
                          CurReg#client_sub{qos = NewQoS, client_seq = NewSeq},
                          Clients)},
                      {reply,ok,S1};
                  #client_sub{monref = OldRef, pid = OldPid} when OldPid =/= NewPid ->
                      mqtt_sub_repo:save_sub(Filter,NewSub),
                      %% replace existing Pid
                      S1 = S#state{monref_idx = maybe_demonitor_reg(OldRef,Mon)},
  