anchor.diff:  select_piece_for_queueing(S, N) ->
       true = queue:is_empty(S#state.request_queue),
       case etorrent_t_state:request_new_piece(S#state.state_pid,
  -					 S#state.piece_set) of
  +					    S#state.piece_set) of
   	{ok, PieceNum, PieceSize} ->
   	    {ok, Chunks, NumChunks} = chunkify(PieceNum, PieceSize),
   	    {ok, ChunkDict} = build_chunk_dict(Chunks),
  
positive.code: %% Description: Make the socket active and configure it to bittorrent
  %%   specifications.
  %%--------------------------------------------------------------------
  enable_socketorrent_messages(Socket) ->
      inet:setopts(Socket, [binary, {active, true}, {packet, 4}]).
  
  %%--------------------------------------------------------------------
  %% Function: unqueue_all_pieces/1
  %% Description: Unqueue all queued pieces at the other end
  %%--------------------------------------------------------------------
  unqueue_all_pieces(S) ->
      Requests = sets:to_list(S#state.remote_request_set),
      Q = S#state.request_queue,
      NQ = queue:join(queue:from_list(Requests),
  		    Q),
      S#state{remote_request_set = sets:new(),
  	     request_queue = NQ}.
  
  
negative.code: report_errornous_piece(Index, Offset, Len, S) ->
      error_logger:warning_msg(
        "Peer ~s sent us chunk ~p have no piece_request on~nRequests: ~p~n~p~n",
        [S#state.peer_id, {Index, Offset, Len}, get_requests(S), get_queues(S)]).
  
  delete_piece(Index, Offset, Len, S) ->
      case delete_piece_from_request_sets(Index, Offset, Len, S) of
  	{ok, NS} ->
  	    NS;
  	out_of_band ->
  	    S
      end.
  
  handle_store_piece(Index, S) ->
      case check_and_store_piece(Index, S) of
  	ok ->
  	    PR = lists:keydelete(Index, 1, S#state.piece_request),
  	    {ok, S#state{piece_request = PR}};
  	wrong_hash ->
  	    stop
      end.
  
  handle_update_piece(Index, Offset, Len, Data, GBT, N, S) ->
      case update_with_new_piece(Index, Offset, Len, Data, GBT, N, S) of
  	{done, NS} ->
  	    handle_store_piece(Index, NS);
  	{not_done, NS} ->
  	    {ok, NS}
      end.
  
  handle_got_chunk(Index, Offset, Data, Len, S) ->
      NS = delete_piece(Index, Offset, Len, S),
      case lists:keysearch(Index, 1, NS#state.piece_request) of
  	false ->
  	    report_errornous_piece(Index, Offset, Len, NS),
  	    stop;
  	{value, {_CurrentIndex, GBT, N}} ->
  	    handle_update_piece(Index, Offset, Len, Data, GBT, N, NS)
      end.
  
  check_and_store_piece(Index, S) ->
      case lists:keysearch(Index, 1, S#state.piece_request) of
  