anchor.diff:      gen_server:call(?MODULE, ping).
   
   %% Gen Server handlers
  -handle_call({spawn_clients, _Number, _Args},
  -            _From,
  -            State = #server_state{limit = Limit}) when Limit =< 0 ->
  +handle_call(Call = {spawn_clients, _Number, _Args}, _From, State) ->
       %% Informs the caller in case of reaching the running clients limit...
  -    {reply, {error, "Max number of clients reached."}, State};
  -
  -handle_call(Call = {spawn_clients, _Number, _Args}, _From, State) ->
       %% ...or proceeds spawning them asynchronously.
  -    gen_server:cast(?MODULE, Call),
  -    {reply, ok, State};
  -
  -handle_call(clients_status, _From, State = #server_state{clients = Clients}) ->
  -    Stats = do_collect_stats(Clients),
  +    case State#server_state.limit =< 0 of
  +        true  -> {reply, {error, "Max number of clients reached."}, State};
  +        false -> gen_server:cast(?MODULE, Call),
  +                 {reply, ok, State}
  +    end;
  +
  +handle_call(clients_status, _From, State) ->
  +    Stats = do_collect_stats(State#server_state.clients),
       {reply, Stats, State};
   
   handle_call(ping, _From, State) ->
       {reply, pong, State}.
   
  -handle_cast({spawn_clients, Number, Args},
  -            State = #server_state{limit = Limit, supervisor = Supervisor, clients = Clients}) ->
  +handle_cast({spawn_clients, Number, Args}, State) ->
  +    #server_state{limit = Limit, supervisor = Supervisor, clients = Clients} = State,
       NumNewClients = max(0, min(Number, Limit - Number)),
       case NumNewClients of
           Number -> lager:info("Spawning ~p new clients...", [Number]);
  
positive.code:              {stop, shutdown, State}
      end.
  
  handle_info({'DOWN', _Ref, process, Pid, Reason},
              State = #server_state{limit = Limit, clients = Clients}) ->
      lager:info("Removing terminated FSM: ~p", [{Pid, Reason}]),
      case gb_sets:is_element(Pid, Clients) of
          true  -> {noreply, State#server_state{limit = Limit + 1, clients = gb_sets:delete(Pid, Clients)}};
          false -> {noreply, State}
  
negative.code:     NewClients = do_spawn_clients(NumNewClients, Supervisor, Args, Clients),
      {noreply, State#server_state{limit = Limit - NumNewClients, clients = NewClients}};
  
  handle_cast({disconnect_clients, Number}, State) ->
      do_disconnect_clients(Number, gb_sets:next(gb_sets:iterator(State#server_state.clients))),
      {noreply, State};
  
  handle_cast({kill_clients, Number}, State) ->
      do_kill_clients(Number, gb_sets:next(gb_sets:iterator(State#server_state.clients))),
      %% ?MODULE:handle_info/2 takes care of removing killed clients from Clients.
      {noreply, State};
  
  