anchor.diff:  
   
   flush_waiters(State, Lang) ->
  -    case dict:fetch(Lang, State#state.counts) of
  -        Count when Count < State#state.hard_limit ->
  -            case get_waiting_client(Lang) of
  -                #client{} = Client ->
  +    CanSpawn = can_spawn(State, Lang),
  +    case get_waiting_client(Lang) of
  +        #client{from = From} = Client ->
  +            case find_proc(Client) of
  +                {ok, ProcInt} ->
  +                    Proc = assign_proc(Client, ProcInt),
  +                    gen_server:reply(From, {ok, Proc, State#state.config}),
  +                    remove_waiting_client(Client),
  +                    flush_waiters(State, Lang);
  +                {error, Error} ->
  +                    gen_server:reply(From, {error, Error}),
  +                    remove_waiting_client(Client),
  +                    flush_waiters(State, Lang);
  +                not_found when CanSpawn ->
                       NewState = spawn_proc(State, Client),
  +                    remove_waiting_client(Client),
                       flush_waiters(NewState, Lang);
  -                undefined ->
  +                not_found ->
                       State
               end;
  -        _ ->
  +        undefined ->
               State
       end.
   
  
positive.code:     {ok, undefined}.
  
  
  find_proc(State, Client, [Fun | FindFuns]) ->
      try iter_procs(Client#client.lang, Fun, undefined) of
          {not_found, _} ->
              find_proc(State, Client, FindFuns);
          {ok, Proc} ->
              {reply, {ok, Proc, State#state.config}, State}
      catch error:Reason ->
          couch_log:error("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]),
          {reply, {error, Reason}, State}
      end;
  find_proc(State, Client, []) ->
      {noreply, maybe_spawn_proc(State, Client)}.
  
  
  iter_procs(Lang, Fun, Acc) when is_binary(Lang) ->
      Pattern = #proc_int{lang=Lang, client=undefined, _='_'},
      MSpec = [{Pattern, [], ['$_']}],
      case ets:select_reverse(?PROCS, MSpec, 25) of
          '$end_of_table' ->
              {not_found, Acc};
          Continuation ->
              iter_procs_int(Continuation, Fun, Acc)
      end.
  
  
  iter_procs_int({[], Continuation0}, Fun, Acc) ->
      case ets:select_reverse(Continuation0) of
          '$end_of_table' ->
              {not_found, Acc};
          Continuation1 ->
              iter_procs_int(Continuation1, Fun, Acc)
      end;
  iter_procs_int({[Proc | Rest], Continuation}, Fun, Acc0) ->
      case Fun(Proc, Acc0) of
          {ok, Acc1} ->
              iter_procs_int({Rest, Continuation}, Fun, Acc1);
          {stop, Acc1} ->
              {ok, Acc1}
      end.
  
  
  maybe_spawn_proc(State, Client) ->
      case dict:find(Client#client.lang, State#state.counts) of
      {ok, Count} when Count >= State#state.hard_limit ->
          add_waiting_client(Client),
          State;
      _ ->
          spawn_proc(State, Client)
      end.
  
  
  
negative.code:     {reply, ets:select_count(?PROCS, MatchSpec), State};
  
  handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, From, State) ->
      LangStr = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
      Lang = couch_util:to_binary(LangStr),
      Client = #client{from=From, lang=Lang, ddoc=DDoc, ddoc_key=DDocKey},
      add_waiting_client(Client),
      {noreply, flush_waiters(State, Lang)};
  
  handle_call({get_proc, LangStr}, From, State) ->
      Lang = couch_util:to_binary(LangStr),
      Client = #client{from=From, lang=Lang},
      add_waiting_client(Client),
      {noreply, flush_waiters(State, Lang)};
  
  handle_call({ret_proc, #proc{client=Ref} = Proc}, _From, State) ->
      erlang:demonitor(Ref, [flush]),
  