anchor.diff:                      case orddict:is_key(ClientId,Subs) of
                           true ->
                               ok = mnesia:write(S#mqtt_sub{subs = orddict:erase(ClientId,Subs)});
  -                        false -> ok
  +                        false ->
  +                            ok
                       end
               end
           end,
       mnesia_do(Fun).
   
  +
  +load(Filter) ->
  +    load(self(),Filter).
  +
  +load(Pid,Filter) ->
  +    Fun =
  +        fun() ->
  +            R =
  +                case mnesia:read(?SUB_RECORD, Filter, write) of
  +                    [] ->   new(Filter);
  +                    [S]->   S
  +                end,
  +            NewSeq = R#mqtt_sub.seq,
  +            mnesia:write(R#mqtt_sub{pid = Pid,seq = NewSeq+1}),
  +            R#mqtt_sub.subs
  +        end,
  +    Subs = mnesia_do(Fun),
  +    orddict:to_list(Subs).
   
   %% @doc
   %% Gets a list of ALL subscriptions matching a topic, selecting the one with the highest QoS
  
positive.code: -record(mqtt_sub, {
      filter,
      subs,
      topic,
      client_id,
      qos
  }).
  
  
  
negative.code:         orddict:new(), AllSubs),
      orddict:to_list(Merged).
  
  
  %% @doc
  %% Gets the Pids of the Subs matching the given topic
  %% @end
  -spec get_matching_subs(Topic::topic()) -> [{Filter::binary(),Pid::pid()}].
  
  get_matching_subs(Topic) ->
      Patterns = mqtt_topic:explode(Topic),
      Spec = [{
          #mqtt_sub{filter = '$1', pid = '$2', _ = '_'},
          [{'=:=', '$1', P}],
          ['$2']
      } || P <- Patterns],
      mnesia:dirty_select(?SUB_RECORD, Spec).
  
  clear(Filter) ->
      claim(Filter,undefined).
  
  claim(Filter,Pid) ->
      Fun =
          fun() ->
              case mnesia:read(?SUB_RECORD,Filter,write) of
                  [] ->
                      ok = mnesia:write(#mqtt_sub{filter = Filter,pid = Pid});
                  [S = #mqtt_sub{pid = OldPid}] when OldPid =/= Pid ->
                      ok = mnesia:write(S#mqtt_sub{pid = Pid})
              end
          end,
      mnesia_do(Fun).
  
  get_sub(Filter) ->
      Spec = {
          #mqtt_sub{filter = '$1', pid = '$2', _ = '_'},
          [{'=:=', '$1', Filter}],
          ['$2']
      },
      case mnesia:dirty_select(?SUB_RECORD, Spec) of
          [] -> error;
          [Pid] -> {ok,Pid}
      end.
  
  
  %% ======================================================================
  %% PRIVATE Misc
  %% ======================================================================
  
  mnesia_do(Fun) ->
  