anchor.diff:          false -> log:log(error, "req. to delete non watched pid~n"),
                    State;
           Entry ->
  -            NewEntry = setelement(2, Entry, element(2, Entry) - 1),
  -            NewRemPids =
  -                case element(2, NewEntry) of
  -                    0 ->
  -                        RemHBS = state_get_rem_hbs(State),
  -                        case comm:make_local(RemHBS) of
  -                            fd -> comm:send(RemHBS, {del_watching_of_via_fd, comm:this(), WatchedPid});
  -                            _ -> comm:send(RemHBS, {del_watching_of, WatchedPid})
  -                        end,
  -                        lists:delete(WatchedPid, RemPids);
  -                    _ -> lists:keyreplace(WatchedPid, 1, RemPids, NewEntry)
  +            TmpEntry = rempid_dec(Entry),
  +            NewEntry =
  +                case {rempid_refcount(TmpEntry),
  +                      rempid_get_pending_demonitor(TmpEntry)} of
  +                    {0, false} -> %% dec to 0 and triggger new delayed message
  +                        Time = os:timestamp(),
  +                        %% delayed demonitoring: remember current time
  +                        %% self-inform on pending demonitoring with current
  +                        %% time.
  +                        %% actually delete if timestamp of the entry is
  +                        %% still the same after delay
  +                        msg_delay:send_local(
  +                          1, self(),
  +                          {check_delayed_del_watching_of, WatchedPid, Time}),
  +                        rempid_set_last_modified(TmpEntry, Time);
  +                    {0, true} -> %% dec to 0 and no new delayed message needed
  +                        TmpEntry;
  +                    _ -> TmpEntry
                   end,
  +            NewRemPids = lists:keyreplace(WatchedPid, 1, RemPids, NewEntry),
               state_set_rem_pids(State, NewRemPids)
       end.
   
  
positive.code: 
  on({pong, _Subscriber, RemoteDelay}, State) ->
      ?TRACEPONG("Pinger pong for ~p~n", [_Subscriber]),
      Now = erlang:now(),
      LastPong = state_get_last_pong(State),
      CrashedAfter = state_get_crashed_after(State),
      PongDelay = abs(timer:now_diff(Now, LastPong)),
  
negative.code: state_set_crashed_after(State, Val) -> setelement(4, State, Val).
  -spec state_get_table(state()) -> atom().
  state_get_table(State)              -> element(5, State).
  -spec state_get_monitors(state())   -> [{comm:mypid(), reference()}].
  state_get_monitors(State)           -> element(6, State).
  -spec state_set_monitors(state(), [{comm:mypid(), reference()}]) -> state().
  state_set_monitors(State, Val)      -> setelement(6, State, Val).
  