anchor.diff:      end,
       
       Cmd = lists:flatten(io_lib:format("bundle exec \"ruby ./src/rack_instance.rb -r ~s -e ~s\"", [AppRoot, RailsEnv])),
  -	[spawn(?MODULE, init_instance_manager, [Cmd, WaitThreshold]) || _ <- lists:seq(1, Count)].
  -
  -init_instance_manager(Cmd, WaitThreshold) ->
  +	[spawn(?MODULE, init_instance_manager, [Cmd, WaitThreshold, MaxRequests]) || _ <- lists:seq(1, Count)].
  +
  +init_instance_manager(Cmd, WaitThreshold, MaxRequests) ->
   	%% Spawn a process to run the rack instance
   	RackPid = spawn_ruby_instance(Cmd),
   	%% Join the rack instance manager to the process group
  
positive.code:                     %% for simplicity we'll reverse the lis of queued
                      %% requests and process the most recent requests first
                      %% and finally get back to the terminate message.
  			        instance_manager_loop(RackPid, {busy, lists:reverse(QueuedRequests)}, WaitThreshold)
              end;
  		terminate -> 
  			instance_manager_loop(RackPid, {busy, [terminate | QueuedRequests]}, WaitThreshold);
          threshold_elapsed ->
  			instance_manager_loop(RackPid, {busy, QueuedRequests}, WaitThreshold)
  	end;
  instance_manager_loop(RackPid, {clogged, []}, WaitThreshold) ->
      receive
  		{Requester, {request, Req}} -> 
              pg2:get_closest_pid(request_pool) ! {Requester, {request, Req}},
  			instance_manager_loop(RackPid, {clogged, []}, WaitThreshold);
  		{RackPid, Requester, Result} -> 
              %% Received response from current request.
              %% Notify the requesting process
  			Requester ! {self(), Result},
              instance_manager_loop(RackPid, {busy, []}, WaitThreshold);
  		terminate -> 
              pg2:get_closest_pid(request_pool) ! terminate,
  			instance_manager_loop(RackPid, {clogged, []}, WaitThreshold)
      end;
  instance_manager_loop(RackPid, {clogged, [_TimerRef | QueuedRequests]}, WaitThreshold) ->
      %% Send all requests queued in RequestList to be handled
      %% by the backup request pool of ruby instances.
      [pg2:get_closest_pid(request_pool) ! QueuedRequestData || QueuedRequestData <- lists:reverse(QueuedRequests)],
  
negative.code: 	end,
  
  	%% Begin instance manager loop
  	instance_manager_loop(RackPid, {idle, []}, WaitThreshold, Cmd, {0, MaxRequests}).
  	
  spawn_ruby_instance(Cmd) ->
      spawn(fun() ->
  