anchor.diff:    {next_state, after_start, State}.
   
   pre_stop(timeout, #state{timer = Timer} = State) ->
  +  ?D({pre_stop, stop}),
     Ref = make_ref(),
     erlang:send_after(Timer, self(), {stop, Ref}),
     {next_state, stop, #state{stop_ref = Ref} = State};
   
   pre_stop({pool_connected, Node}, #state{node_counter = N, active_nodes = Nodes, passive_nodes = PassiveNodes, timer = Timer, node_activity = Activities} = State) ->
  +  ?D({pre_stop, stop}),
     Ref = make_ref(),
     erlang:send_after(Timer, self(), {stop, Ref}),
     {next_state, stop, State#state{node_counter = N + 1, active_nodes = [Node | Nodes], passive_nodes = lists:delete(Node, PassiveNodes), stop_ref = Ref, node_activity = maps:put(Node, true, Activities)}};
  
positive.code:       N -> start;
        _ -> monitoring
      end,
    {next_state, NextState, State#state{indicator = NewInd, node_counter = N - 1, active_nodes = lists:delete(Node, Nodes), passive_nodes = [Node | PassiveNodes]}};
  
  monitoring({pool_enabled, Node}, #state{indicator = Ind, active_nodes = [Node], node_activity = Activities} = State) ->
    {next_state, monitoring, State#state{indicator = Ind - 1, node_activity = maps:put(Node, true, Activities)}};
  
  monitoring({pool_enabled, Node}, #state{indicator = Ind, node_activity = Activities} = State) ->
    {next_state, pre_stop, State#state{indicator = Ind - 1, node_activity = maps:put(Node, true, Activities)}, 1000};
  
  monitoring({pool_disabled, Node}, #state{indicator = Ind, passive_nodes = [], node_activity = Activities} = State) ->
    {next_state, monitoring, State#state{indicator = Ind + 1, node_activity = maps:put(Node, false, Activities)}};
  
  monitoring({pool_disabled, Node}, #state{indicator = Ind, node_counter = N, node_activity = Activities} = State) when N == Ind + 1 ->
    {next_state, start, State#state{indicator = Ind + 1, node_activity = maps:put(Node, false, Activities)}};
  
  monitoring({pool_disabled, Node}, #state{indicator = Ind, node_activity = Activities} = State)->
    {next_state, monitoring, State#state{indicator = Ind + 1, node_activity = maps:put(Node, false, Activities)}};
  
  monitoring(_Event, State) ->
    {next_state, stop, State}.
  
  start(high_idle_time, #state{passive_nodes = [Node |_], node_to_id = NodeToId, timer = Timer} = State) ->
    ?D({start_new_instance, Node}),
    aws_cli:start_instance(maps:get(Node, NodeToId)),
    Ref = make_ref(),
    erlang:send_after(Timer, self(), {start, Ref}),
    {next_state, after_start, State#state{start_ref = Ref}};
  
  start({pool_enabled, Node}, #state{indicator = Ind, node_activity = Activities} = State) ->
    {next_state, monitoring, State#state{indicator = Ind - 1, node_activity = maps:put(Node, true, Activities)}};
  
  start({pool_disabled, Node}, #state{indicator = Ind, node_activity = Activities} = State) ->
    {next_state, start, State#state{indicator = Ind + 1, node_activity = maps:put(Node, false, Activities)}};
  
  start({pool_connected, Node}, #state{node_counter = N, active_nodes = Nodes, passive_nodes = PassiveNodes, node_activity = Activities} = State) ->
    {next_state, monitoring, State#state{node_counter = N + 1, active_nodes = [Node | Nodes], passive_nodes = lists:delete(Node, PassiveNodes), node_activity = maps:put(Node, true, Activities)}};
  
  start({pool_down, Node}, #state{indicator = Ind, node_counter = N, active_nodes = Nodes, passive_nodes = PassiveNodes, node_activity = Activities} = State) ->
  
negative.code:   {next_state, after_start, State#state{indicator = Ind + 1, node_activity = maps:put(Node, false, Activities)}};
  
  after_start({pool_connected, Node}, #state{node_counter = N, active_nodes = Nodes, passive_nodes = PassiveNodes, node_activity = Activities} = State) ->
    ?D({after_start, monitoring}),
    {next_state, monitoring, State#state{node_counter = N + 1, active_nodes = [Node | Nodes], passive_nodes = lists:delete(Node, PassiveNodes), node_activity = maps:put(Node, true, Activities)}};
  
  after_start({pool_down, Node}, #state{indicator = Ind, node_counter = N, active_nodes = Nodes, passive_nodes = PassiveNodes, node_activity = Activities} = State) ->
  