anchor.diff:                  true = ets:update_element(?PROCS, Pid, [
                       {#proc_int.client, undefined}
                   ]),
  -                maybe_assign_proc(State, ProcInt)
  +                State
           end;
       false ->
           remove_proc(State, ProcInt)
       end,
       flush_waiters(NewState, Lang).
   
  -maybe_assign_proc(#state{} = State, ProcInt) ->
  -    #proc_int{lang = Lang} = ProcInt,
  -    case get_waiting_client(Lang) of
  -        #client{from = From} = Client ->
  -            Proc = assign_proc(Client, ProcInt#proc_int{client=undefined}),
  -            gen_server:reply(From, {ok, Proc, State#state.config}),
  -            State;
  -        undefined ->
  -            State
  -    end.
   
   remove_proc(State, #proc_int{}=Proc) ->
       ets:delete(?PROCS, Proc#proc_int.pid),
  
positive.code: 
  
  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 ->
                      NewState = spawn_proc(State, Client),
                      flush_waiters(NewState, Lang);
                  undefined ->
                      State
              end;
          _ ->
              State
      end.
  
  
negative.code:     {ok, undefined}.
  
  
  find_proc(#client{lang = Lang, ddoc_key = undefined}) ->
      Pred = fun(_) ->
          true
      end,
      find_proc(Lang, Pred);
  find_proc(#client{lang = Lang, ddoc = DDoc, ddoc_key = DDocKey} = Client) ->
      Pred = fun(#proc_int{ddoc_keys = DDocKeys}) ->
          lists:member(DDocKey, DDocKeys)
      end,
      case find_proc(Lang, Pred) of
          not_found ->
              case find_proc(Client#client{ddoc_key=undefined}) of
                  {ok, Proc} ->
                      teach_ddoc(DDoc, DDocKey, Proc);
                  Else ->
                      Else
              end;
          Else ->
              Else
      end.
  
  find_proc(Lang, Fun) ->
      try iter_procs(Lang, Fun)
      catch error:Reason ->
          StackTrace = erlang:get_stacktrace(),
          couch_log:error("~p ~p ~p", [?MODULE, Reason, StackTrace]),
          {error, Reason}
      end.
  
  
  iter_procs(Lang, Fun) 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;
          Continuation ->
              iter_procs_int(Continuation, Fun)
      end.
  
  
  iter_procs_int({[], Continuation0}, Fun) ->
      case ets:select_reverse(Continuation0) of
          '$end_of_table' ->
              not_found;
          Continuation1 ->
              iter_procs_int(Continuation1, Fun)
      end;
  iter_procs_int({[Proc | Rest], Continuation}, Fun) ->
      case Fun(Proc) of
          true ->
              {ok, Proc};
          false ->
              iter_procs_int({Rest, Continuation}, Fun)
      end.
  
  
  