anchor.diff:  
   % Private API
   
  -get_query_server_config() ->
  -    ReduceLimit = list_to_atom(
  -        couch_config:get("query_server_config","reduce_limit","true")),
  -    {[{<<"reduce_limit">>, ReduceLimit}]}.
  -
  -new_process(Langs, Lang) ->
  -    case ets:lookup(Langs, Lang) of
  -    [{Lang, Mod, Func, Arg}] ->
  -        {ok, Pid} = apply(Mod, Func, Arg),
  -        {ok, #proc{lang=Lang,
  -                   pid=Pid,
  -                   % Called via proc_prompt, proc_set_timeout, and proc_stop
  -                   prompt_fun={Mod, prompt},
  -                   set_timeout_fun={Mod, set_timeout},
  -                   stop_fun={Mod, stop}}};
  +add_to_waitlist(Info, From, #qserver{waitlist=Waitlist}=Server) ->
  +    Server#qserver{waitlist=[{Info, From}|Waitlist]}.
  +
  +service_waitlist(#qserver{waitlist=[]}=Server) ->
  +    Server;
  +service_waitlist(#qserver{waitlist=Waitlist}=Server) ->
  +    [Oldest|RevWList] = lists:reverse(Waitlist),
  +    case service_waiting(Oldest, Server) of
  +    ok ->
  +        Server#qserver{waitlist=lists:reverse(RevWList)};
  +    wait ->
  +        Server#qserver{waitlist=Waitlist}
  +    end.
  +
  +% todo get rid of duplication
  +service_waiting({{#doc{body={Props}}=DDoc, DDocKey}, From}, Server) ->
  +    Lang = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
  +    case lang_proc(Lang, Server, fun(Procs) ->
  +            % find a proc in the set that has the DDoc
  +            proc_with_ddoc(DDoc, DDocKey, Procs)
  +        end) of
  +    {ok, Proc} ->
  +        gen_server:reply(From, {ok, Proc, Server#qserver.config}),
  +        ok;
  +    wait -> % this should never happen
  +        wait;
  +    Error ->
  +        gen_server:reply(From, Error),
  +        ok
  +    end;
  +service_waiting({{Lang}, From}, Server) ->
  +    case lang_proc(Lang, Server, fun([P|Procs]) ->
  +            {ok, P}
  +        end) of
  +    {ok, Proc} ->
  +        gen_server:reply(From, {ok, Proc, Server#qserver.config}),
  +        ok;
  +    wait -> % this should never happen
  +        wait;
  +    Error ->
  +        gen_server:reply(From, Error),
  +        ok
  +    end.
  +
  +lang_proc(Lang, #qserver{
  +        langs=Langs,
  +        pid_procs=PidProcs,
  +        lang_procs=LangProcs,
  +        lang_limits=LangLimits}, PickFun) ->
  +    % Note to future self. Add max process limit.
  +    case ets:lookup(LangProcs, Lang) of
  +    [{Lang, [P|Procs]}] ->
  +        {ok, Proc} = PickFun([P|Procs]),
  +        rem_from_list(LangProcs, Lang, Proc),
  +        {ok, Proc};
       _ ->
  -        {unknown_query_language, Lang}
  +        case (catch new_process(Langs, LangLimits, Lang)) of
  +        {ok, Proc} ->
  +            add_value(PidProcs, Proc#proc.pid, Proc),
  +            {ok, Proc2} = PickFun([Proc]);
  +        ErrorOrWait ->
  +            ErrorOrWait
  +        end
  +    end.
  +
  +new_process(Langs, LangLimits, Lang) ->
  +    [{Lang, Lim, Current}] = ets:lookup(LangLimits, Lang),
  +    if (Lim == 0) or (Current < Lim) -> % Lim == 0 means no limit
  +        % we are below the limit for our language, make a new one
  +        case ets:lookup(Langs, Lang) of
  +        [{Lang, Mod, Func, Arg}] ->
  +            {ok, Pid} = apply(Mod, Func, Arg),
  +            true = ets:insert(LangLimits, {Lang, Lim, Current+1}),
  +            {ok, #proc{lang=Lang,
  +                       pid=Pid,
  +                       % Called via proc_prompt, proc_set_timeout, and proc_stop
  +                       prompt_fun={Mod, prompt},
  +                       set_timeout_fun={Mod, set_timeout},
  +                       stop_fun={Mod, stop}}};
  +        _ ->
  +            {unknown_query_language, Lang}
  +        end;
  +    true ->
  +        wait
       end.
   
   proc_with_ddoc(DDoc, DDocKey, LangProcs) ->
  
positive.code:         end,
          rem_value(PidProcs, Pid),
          catch rem_from_list(LangProcs, Proc#proc.lang, Proc),
          {noreply, Server};
      [] ->
          case Status of
          normal ->
  
negative.code: get_ddoc_process(#doc{} = DDoc, DDocKey) ->
      % remove this case statement
      case gen_server:call(couch_query_servers, {get_proc, DDoc, DDocKey}) of
      {ok, Proc, {QueryConfig}} ->
          % process knows the ddoc
          case (catch proc_prompt(Proc, [<<"reset">>, {QueryConfig}])) of
          true ->
              proc_set_timeout(Proc, couch_util:get_value(<<"timeout">>, QueryConfig)),
              link(Proc#proc.pid),
              gen_server:call(couch_query_servers, {unlink_proc, Proc#proc.pid}),
              Proc;
  