anchor.diff:          {empty, Waiting2} ->
               Busy2 = State#state.busy -- [Worker],
               Free2 = [Worker | State#state.free];
  -        {{value, From}, Waiting2} ->
  +        {{value, {Pid, _} = From}, Waiting2} ->
  +            monitor_use(Pid, Worker, Callers),
               gen_server:reply(From, {ok, Worker}),
               Busy2 = State#state.busy,
               Free2 = State#state.free
  
positive.code:         [Worker | Free2] ->
             ok
          end,
          NewState = State#state{free = Free2, busy = [Worker | Busy]},
          {reply, {ok, Worker}, NewState}
      end;
  
negative.code:         {noreply, State}
     end.
  
  handle_info({'EXIT', Pid, _Reason}, #state{busy = Busy, free = Free, waiting = Waiting, callers = Callers} = State) ->
      demonitor_worker(Callers,Pid),
      case Free -- [Pid] of
      Free ->
          case Busy -- [Pid] of
          Busy ->
              {noreply, State};
          Busy2 ->
              case queue:out(Waiting) of
              {empty, _} ->
                  {noreply, State#state{busy = Busy2}};
              {{value, {FromPid, _Ref} = From}, Waiting2} ->
                  {ok, Worker} = ibrowse:spawn_link_worker_process(State#state.url),
                  monitor_use(FromPid, Worker, Callers),
                  gen_server:reply(From, {ok, Worker}),
                  {noreply, State#state{busy = [Worker | Busy2], waiting = Waiting2}}
              end
          end;
      Free2 ->
          {noreply, State#state{free = Free2}}
      end;
  
  handle_info({'DOWN', MonitorRef, process, _Pid, _Info},
              #state{callers = Callers} = State) ->
      case ets:match(Callers,{'$1',MonitorRef}) of
      [] ->
          {noreply, State};
      [[Worker]] ->
          handle_cast({release_worker, Worker}, State)
      end.
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State#state{callers = ets:new(callers,[set])}}.
  
  
  terminate(_Reason, State) ->
      lists:foreach(fun ibrowse_http_client:stop/1, State#state.free),
      lists:foreach(fun ibrowse_http_client:stop/1, State#state.busy).
  
  monitor_use(Pid, Worker, Callers) ->
      MonitorRef = erlang:monitor(process, Pid),
      ets:insert(Callers, {Worker, MonitorRef}).
  
  demonitor_worker(Callers, Worker) ->
      case ets:lookup(Callers,Worker) of
      [] -> ok;
      [{Worker, MonRef}] ->
          ets:delete(Callers,Worker),
          erlang:demonitor(MonRef)
      end.
  