anchor.diff:      %% ETS table name, and also the registered process name (self())
       scope :: atom(),
       %% monitored local processes and groups they joined
  -    monitors = #{} :: #{pid() => {MRef :: reference(), Groups :: [group()]}},
  +    local = #{} :: #{pid() => {MRef :: reference(), Groups :: [group()]}},
       %% remote node: scope process monitor and map of groups to pids for fast sync routine
  -    nodes = #{} :: #{pid() => {reference(), #{group() => [pid()]}}}
  +    remote = #{} :: #{pid() => {reference(), #{group() => [pid()]}}}
   }).
   
   -type state() :: #state{}.
  
positive.code:             ets:insert(Scope, {Group, Pids, []})
      end.
  
  join_remote_map(Group, Pid, RemoteGroups) when is_pid(Pid) ->
      maps:update_with(Group, fun (List) -> [Pid | List] end, [Pid], RemoteGroups);
  join_remote_map(Group, Pids, RemoteGroups) ->
      maps:update_with(Group, fun (List) -> Pids ++ List end, Pids, RemoteGroups).
  
  leave_monitors(Pid, Group, Monitors) when is_pid(Pid) ->
      case maps:find(Pid, Monitors) of
          {ok, {MRef, [Group]}} ->
              erlang:demonitor(MRef),
              maps:remove(Pid, Monitors);
          {ok, {MRef, Groups}} ->
              case lists:member(Group, Groups) of
                  true ->
                      maps:put(Pid, {MRef, lists:delete(Group, Groups)}, Monitors);
                  false ->
                      Monitors
              end;
          _ ->
              Monitors
      end;
  leave_monitors([], _Group, Monitors) ->
      Monitors;
  leave_monitors([Pid | Tail], Group, Monitors) ->
      leave_monitors(Tail, Group, leave_monitors(Pid, Group, Monitors)).
  
  leave_local_group(Scope, Group, Pid) when is_pid(Pid) ->
      case ets:lookup(Scope, Group) of
          [{Group, [Pid], [Pid]}] ->
              ets:delete(Scope, Group);
  
negative.code:             true = ets:insert(Scope, {Group, AllNewPids, LocalPids}),
              sync_groups(Scope, NewRemoteGroups, Tail);
          error ->
              join_remote_update_ets(Scope, Group, Pids),
              sync_groups(Scope, RemoteGroups, Tail)
      end.
  
  join_local(Pid, Group, Local) when is_pid(Pid) ->
      case maps:find(Pid, Local) of
          {ok, {MRef, Groups}} ->
              maps:put(Pid, {MRef, [Group | Groups]}, Local);
          error ->
              MRef = erlang:monitor(process, Pid),
              Local#{Pid => {MRef, [Group]}}
      end;
  join_local([], _Group, Local) ->
      Local;
  join_local([Pid | Tail], Group, Local) ->
      join_local(Tail, Group, join_local(Pid, Group, Local)).
  
  join_local_update_ets(Scope, Group, Pid) when is_pid(Pid) ->
      case ets:lookup(Scope, Group) of
          [{Group, All, Local}] ->
              ets:insert(Scope, {Group, [Pid | All], [Pid | Local]});
          [] ->
              ets:insert(Scope, {Group, [Pid], [Pid]})
      end;
  join_local_update_ets(Scope, Group, Pids) ->
      case ets:lookup(Scope, Group) of
          [{Group, All, Local}] ->
              ets:insert(Scope, {Group, Pids ++ All, Pids ++ Local});
  