anchor.diff:  %% @doc Message handler during start up phase (will change to on_active/2 when a
   %%      'activate_clustering' message is received).
   -spec on_inactive(message(), state_inactive()) -> state_inactive();
  -                ({activate_clustering}, state_inactive()) -> {'$gen_component', [{on_handler, Handler::gen_component:handler()}], State::state_active()}.
  -on_inactive({activate_clustering},
  -            {inactive, QueuedMessages, ResetTriggerState, ClusterTriggerState}) ->
  +                ({activate_clustering}, state_inactive())
  +            -> {'$gen_component', [{on_handler, Handler::gen_component:handler()}], State::state_active()}.
  +on_inactive({activate_clustering}, #state_inactive{
  +                                    queued_messages=QueuedMessages
  +                                    ,reset_trigger_state=ResetTriggerState
  +                                    ,cluster_trigger_state=ClusterTriggerState
  +                                    ,radius=R
  +                                }) ->
       log:log(info, "[ Clustering ~.0p ] activating...~n", [comm:this()]),
       ResetTriggerState2 = trigger:now(ResetTriggerState),
       ClusterTriggerState2 = trigger:now(ClusterTriggerState),
       msg_queue:send(QueuedMessages),
  -    gen_component:change_handler({dc_centroids:empty_centroids_list(), 0, ResetTriggerState2, ClusterTriggerState2},
  -                                 fun ?MODULE:on_active/2);
  -
  -on_inactive(Msg = {query_clustering, _Pid},
  -            {inactive, QueuedMessages, ResetTriggerState, ClusterTriggerState}) ->
  -    {inactive, msg_queue:add(QueuedMessages, Msg), ResetTriggerState, ClusterTriggerState};
  -
  -on_inactive({query_epoch, _Pid} = Msg, 
  -            {inactive, QueuedMessages, ResetTriggerState, ClusterTriggerState}) ->
  -    {inactive, msg_queue:add(QueuedMessages, Msg), ResetTriggerState, ClusterTriggerState};
  -
  -on_inactive({web_debug_info, Requestor},
  -            {inactive, QueuedMessages, _ResetTriggerState, _ClusterTriggerState} = State) ->
  +    StateActive = #state_active{
  +        centroids = dc_centroids:empty_centroids_list()
  +        , reset_trigger_state = ResetTriggerState2
  +        , cluster_trigger_state = ClusterTriggerState2
  +        , radius=R
  +    },
  +    gen_component:change_handler(StateActive, fun ?MODULE:on_active/2)
  +    ;
  +
  +on_inactive(Msg = {query_clustering, _Pid}, #state_inactive{queued_messages=QueuedMessages} = State) ->
  +    State#state_inactive{queued_messages=msg_queue:add(QueuedMessages, Msg)}
  +    ;
  +
  +on_inactive({query_epoch, _Pid} = Msg, #state_inactive{queued_messages=Q} = State) ->
  +    State#state_inactive{queued_messages=msg_queue:add(Q, Msg)}
  +    ;
  +
  +on_inactive({web_debug_info, Requestor}, #state_inactive{queued_messages=Q} = State) ->
       % get a list of up to 50 queued messages to display:
       MessageListTmp = [{"", webhelpers:safe_html_string("~p", [Message])}
  -                  || Message <- lists:sublist(QueuedMessages, 50)],
  -    MessageList = case length(QueuedMessages) > 50 of
  +                  || Message <- lists:sublist(Q, 50)],
  +    MessageList = case length(Q) > 50 of
                         true -> lists:append(MessageListTmp, [{"...", ""}]);
                         _    -> MessageListTmp
                     end,
  
positive.code: -export([init/1, on_inactive/2, on_active/2,
           activate/0, deactivate/0]).
  
  % state of the clustering loop
  -type(state_active() :: {Centroids::dc_centroids:centroids(),
                           LocalEpoch::non_neg_integer(),
                           ResetTriggerState::trigger:state(),
                           ClusterTriggerState::trigger:state()}).
  -type(state_inactive() :: {inactive, QueuedMessages::msg_queue:msg_queue(),
                             ResetTriggerState::trigger:state(),
                             ClusterTriggerState::trigger:state()}).
  %% -type(state() :: state_active() | state_inactive()).
  
  % accepted messages of an initialized dc_clustering process
  
negative.code: init({ResetTrigger, ClusterTrigger}) ->
      ResetTriggerState = trigger:init(ResetTrigger, fun get_clustering_reset_interval/0, reset_clustering),
      ClusterTriggerState = trigger:init(ClusterTrigger, fun get_clustering_interval/0, start_clustering_shuffle),
      Radius = case config:read(dc_clustering_radius) of
          failed -> exit(dc_clustering_radius_not_set);
          R when R > 0 -> R;
          _Else -> exit(dc_clustering_radius_invalid)
      end,
      #state_inactive{
          queued_messages = msg_queue:new()
          , reset_trigger_state = ResetTriggerState
          , cluster_trigger_state = ClusterTriggerState
          , radius=Radius
      }
      .
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Message Loop
  