anchor.diff:  
   -record(state, {
       tab,
  -    config
  +    config,
  +    proc_counts,
  +    waiting
  +}).
  +
  +-record(client, {
  +    timestamp,
  +    from,
  +    lang,
  +    ddoc,
  +    ddoc_key
   }).
   
   start_link() ->
  
positive.code:     TeachFun = fun(Proc0, Acc) ->
          try
              {ok, Proc1} = teach_ddoc(DDoc, DDocKey, Proc0),
              {stop, assign_proc(State#state.tab, Client, Proc1)}
          catch _:_ ->
              {ok, Acc}
          end
      end,
      try iter_procs(State#state.tab, Lang, IterFun, nil) of
      {not_found, _} ->
          case iter_procs(State#state.tab, Lang, TeachFun, nil) of
          {not_found, _} ->
              spawn_link(?MODULE, new_proc, [From, Lang, DDoc, DDocKey]),
              {noreply, State};
          {ok, Proc} ->
              {reply, {ok, Proc, State#state.config}, State}
          end;
      {ok, Proc} ->
          {reply, {ok, Proc, State#state.config}, State}
      catch error:Reason ->
          ?LOG_ERROR("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]),
          {reply, {error, Reason}, State}
      end;
  
  handle_call({get_proc, Lang}, {Client, _} = From, State) ->
      IterFun = fun(Proc, _Acc) ->
          {stop, assign_proc(State#state.tab, Client, Proc)}
      end,
      try iter_procs(State#state.tab, Lang, IterFun, nil) of
      {not_found, _} ->
          spawn_link(?MODULE, new_proc, [From, Lang]),
          {noreply, State};
      {ok, Proc} ->
          {reply, {ok, Proc, State#state.config}, State}
      catch error:Reason ->
          ?LOG_ERROR("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]),
          {reply, {error, Reason}, State}
      end;
  
  handle_call({ret_proc, #proc{client=Ref} = Proc}, _From, State) ->
      erlang:demonitor(Ref, [flush]),
      % We need to check if the process is alive here, as the client could be
      % handing us a #proc{} with a dead one.  We would have already removed the
      % #proc{} from our own table, so the alternative is to do a lookup in the
      % table before the insert.  Don't know which approach is cheaper.
      return_proc(State#state.tab, Proc),
      {reply, true, State};
  
  handle_call(_Call, _From, State) ->
      {reply, ignored, State}.
  
  handle_cast({os_proc_idle, Pid}, #state{tab=Tab}=State) ->
      Limit = config:get("query_server_config", "os_process_soft_limit", "100"),
      case ets:lookup(Tab, Pid) of
          [#proc{client=nil}] ->
              case ets:info(Tab, size) > list_to_integer(Limit) of
                  true ->
                      ?LOG_INFO("Closing idle OS Process: ~p", [Pid]),
                      ets:delete(Tab, Pid),
                      case is_process_alive(Pid) of
  
negative.code: handle_config_change(_, _, _, _, _) ->
      {ok, nil}.
  
  iter_procs(Tab, Lang, Fun, Acc) when is_list(Lang) ->
      iter_procs(Tab, list_to_binary(Lang), Fun, Acc);
  iter_procs(Tab, Lang, Fun, Acc) ->
      Pattern = #proc{lang=Lang, client=nil, _='_'},
      MSpec = [{Pattern, [], ['$_']}],
  