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:     {reply, ets:select_count(?PROCS, MatchSpec), State};
  
  handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, From, State) ->
      {ClientPid, _} = From,
      LangStr = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
      Lang = couch_util:to_binary(LangStr),
      IterFun = fun(Proc, Acc) ->
          case lists:member(DDocKey, Proc#proc_int.ddoc_keys) of
              true ->
                  {stop, assign_proc(ClientPid, Proc)};
              false ->
                  {ok, Acc}
          end
      end,
      TeachFun = fun(Proc0, Acc) ->
          try
              {ok, Proc1} = teach_ddoc(DDoc, DDocKey, Proc0),
              {stop, assign_proc(ClientPid, Proc1)}
          catch _:_ ->
              {ok, Acc}
          end
      end,
      Client = #client{from=From, lang=Lang, ddoc=DDoc, ddoc_key=DDocKey},
      find_proc(State, Client, [IterFun, TeachFun]);
  
  handle_call({get_proc, Lang}, From, State) ->
      {ClientPid, _} = From,
      IterFun = fun(Proc, _Acc) ->
          {stop, assign_proc(ClientPid, Proc)}
      end,
      Client = #client{from=From, lang=couch_util:to_binary(Lang)},
      find_proc(State, Client, [IterFun]);
  
  handle_call({ret_proc, #proc{client=Ref} = Proc}, _From, State) ->
      erlang:demonitor(Ref, [flush]),
  
negative.code:                 true = ets:update_element(?PROCS, Pid, [
                      {#proc_int.client, undefined}
                  ]),
                  State
          end;
      false ->
          remove_proc(State, ProcInt)
      end,
      flush_waiters(NewState, Lang).
  
  
  remove_proc(State, #proc_int{}=Proc) ->
      ets:delete(?PROCS, Proc#proc_int.pid),
  