anchor.diff:      on({crash, Pid}, State);
   on({crash, Pid}, State) ->
       ?TRACE_RTM_MGMT("tx_tm_rtm:on({crash,...}) of Pid ~p~n", [Pid]),
  -    RTMs = state_get_RTMs(State),
  -    NewRTMs = [ case get_rtmpid(RTM) of
  -                    {Pid} ->
  -                        I = get_nth(RTM),
  -                        Name = get_nth_rtm_name(I),
  -                        Key = get_rtmkey(RTM),
  -                        api_dht_raw:unreliable_lookup(
  -                          Key, {get_rtm, comm:this(), Key, Name}),
  -                        rtm_entry_new(Key, unknown, I, unknown);
  -                    _ -> RTM
  -                end
  -                || RTM <- RTMs ],
  -    %% scan over all running transactions and delete this Pid
  -    %% if necessary, takeover the tx and try deciding with abort
  -    NewState = State,
  -%%     NewState = lists:foldl(
  -%%                  fun(X,StateIter) ->
  -%%                          case tx_state:is_tx_state(X) of
  -%%                              true ->
  -%%                                  ct:pal("propose yourself (~.0p/~.0p) for: ~.0p~n",
  -%%                                         [self(),
  -%%                                          pid_groups:group_and_name_of(self()),
  -%%                                          tx_state:get_tid(X)]),
  -%%                                  on({tx_tm_rtm_propose_yourself, tx_state:get_tid(X)}, StateIter);
  -%%                              false -> StateIter
  -%%                          end
  -%%                 end, State, pdb:tab2list(state_get_tablename(State))),
  -
  -    %% no longer use this RTM
  -    ValidRTMs = [ X || X <- NewRTMs, unknown =/= get_rtmpid(X) ],
  -    case length(ValidRTMs) < 3 andalso tx_tm =:= state_get_role(NewState) of
  -        true ->
  -            gen_component:change_handler(
  -              state_set_RTMs(NewState, NewRTMs),
  -              fun ?MODULE:on_init/2);
  -        false -> state_set_RTMs(NewState, NewRTMs)
  -    end;
  -
  +    handle_crash(Pid, State, on);
   %% on({crash, _Pid, _Cookie},
   %%    {_RTMs, _TableName, _Role, _LAcceptor, _GLLearner} = State) ->
   %%     ?TRACE("tx_tm_rtm:on:crash of ~p in Transaction ~p~n", [_Pid, binary_to_term(_Cookie)]),
  
positive.code:                   {[rtm_entry_new(X, unknown, I, unknown) | Acc ], I - 1}
                  end,
                  {[], length(RTM_ids) - 1}, RTM_ids),
      rtm_update(NewRTMs),
      state_set_RTMs(State, NewRTMs);
  
  on_init({update_RTMs}, State) ->
      ?TRACE_RTM_MGMT("tx_tm_rtm:on_init:update_RTMs in Pid ~p ~n", [self()]),
      rtm_update(state_get_RTMs(State)),
      State;
  
  on_init({get_rtm_reply, InKey, InPid, InAcceptor}, State) ->
  
negative.code:     end,
      Result.
  
  handle_crash(Pid, State, Handler) ->
      RTMs = state_get_RTMs(State),
      NewRTMs = [ case get_rtmpid(RTM) of
                      X when unknown =:= X orelse {Pid} =:= X ->
                          I = get_nth(RTM),
                          Name = get_nth_rtm_name(I),
                          Key = get_rtmkey(RTM),
                          api_dht_raw:unreliable_lookup(
                            Key, {get_rtm, comm:this(), Key, Name}),
                          rtm_entry_new(Key, unknown, I, unknown);
                      _ -> RTM
                  end
                  || RTM <- RTMs ],
      
  
      %% scan over all running transactions and delete this Pid
      %% if necessary, takeover the tx and try deciding with abort
      NewState = State,
  %%     NewState = lists:foldl(
  %%                  fun(X,StateIter) ->
  %%                          case tx_state:is_tx_state(X) of
  %%                              true ->
  %%                                  ct:pal("propose yourself (~.0p/~.0p) for: ~.0p~n",
  %%                                         [self(),
  %%                                          pid_groups:group_and_name_of(self()),
  %%                                          tx_state:get_tid(X)]),
  %%                                  on({tx_tm_rtm_propose_yourself, tx_state:get_tid(X)}, StateIter);
  %%                              false -> StateIter
  %%                          end
  %%                 end, State, pdb:tab2list(state_get_tablename(State))),
  
      %% no longer use this RTM
      ValidRTMs = [ X || X <- NewRTMs, unknown =/= get_rtmpid(X) ],
      case length(ValidRTMs) < 3
          andalso tx_tm =:= state_get_role(NewState)
          andalso on =:= Handler of
          true ->
              comm:send_local(self(), {update_RTMs_on_init}),
              gen_component:change_handler(
                state_set_RTMs(NewState, NewRTMs),
                fun ?MODULE:on_init/2);
          false -> state_set_RTMs(NewState, NewRTMs)
      end.
  
  
  
  
  
  
  %% @doc Checks whether config parameters for tx_tm_rtm exist and are
  %%      valid.
  