anchor.diff:  queue_up_requests(S, N) ->
       case queue:out(S#state.request_queue) of
   	{empty, Q} ->
  -	    select_piece_for_queueing(S#state{request_queue = Q}, N);
  +	    select_chunks_for_queueing(S#state{request_queue = Q}, N);
   	{{value, {Index, Offset, Len}}, Q} ->
   	    etorrent_t_peer_send:local_request(S#state.send_pid,
   					    Index, Offset, Len),
  
positive.code: -export([start_link/5, connect/3, choke/1, unchoke/1, interested/1,
  	 send_have_piece/2, complete_handshake/4, uploaded_data/2,
  	stop/1]).
  
  %% Temp API
  -export([chunkify/2]).
  
  %% gen_server callbacks
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  
negative.code:     end.
  
  %%--------------------------------------------------------------------
  %% Function: select_chunks_for_queueing(state(), N) -> ...
  %% Description: Select some chunks for queueing. Then make
  %%  a tail-call into queue_up_requests continuing the queue, or fail
  %%  if no piece is eligible.
  %%--------------------------------------------------------------------
  select_chunks_for_queueing(S, N) ->
      true = queue:is_empty(S#state.request_queue), % Assert the queue is empty.
      case etorrent_t_state:request_new_chunks(S#state.state_pid, S#state.piece_set) of
  	{ok, Chunks, NumChunks} ->
  	    {ok, ChunkDict} = build_chunk_dict(Chunks),
  	    % XXX: In due time, the piece_request entry should be removed from here.
  	    queue_up_requests(S#state{piece_request =
  				      [{1, % XXX: This is a wrong dummy!
  					ChunkDict, NumChunks} | S#state.piece_request],
  				      request_queue = queue:from_list(Chunks)},
  			      N);
  	E when is_atom(E) ->
  	    {partially_queued, S, N, E}
      end.
  %%--------------------------------------------------------------------
  %% Function: build_chunk_dict(list_of_chunks()) -> gb_tree()
  %% Description: Build a gb_tree from the chunks suitable for filling
  