anchor.diff:              pick_chunks(chunkify_piece, {Pid, Id, PieceSet, SoFar, Remaining, none});
           found_chunked ->
               pick_chunks(chunkify_piece, {Pid, Id, PieceSet, SoFar, Remaining, found_chunked});
  -        PieceNum when is_integer(PieceNum) ->
  -	    {ok, Chunks, Size} =
  -                select_chunks_by_piecenum(Id, PieceNum,
  -                                          Remaining, Pid),
  +	Selected when is_list(Selected) ->
  +	    {ok, {PieceNum, Chunks}, Size} =
  +                select_chunks_by_piecenum(Selected, Remaining, Pid),
               pick_chunks(pick_chunked, {Pid, Id,
                                          gb_sets:del_element(PieceNum, PieceSet),
  -                                       [Chunks | SoFar],
  +                                       [{PieceNum, Chunks} | SoFar],
                                          Remaining - Size, Res})
       end;
   
  
positive.code:             ok
      end.
  
  %%--------------------------------------------------------------------
  %% Function: select_chunks_by_piecenum(Id, PieceNum, Num, Pid) ->
  %%     {ok, [{Offset, Len}], Remain}
  %% Description: Select up to Num chunks from PieceNum. Will return either
  %%  {ok, Chunks} if it got all chunks it wanted, or {partial, Chunks, Remain}
  %%  if it got some chunks and there is still Remain chunks left to pick.
  %%--------------------------------------------------------------------
  select_chunks_by_piecenum(Id, Index, Max, Pid) ->
      R = ets:lookup(?TAB, {Id, Index, not_fetched}),
      %% Get up to Max chunks
      {Return, _Rest} = etorrent_utils:gsplit(Max, R),
      [_|_] = Return, %% Assert.
      %% Assign chunk to us
      Chunks = [begin
  		  ets:delete_object(?TAB, C),
  		  ets:insert(?TAB,
  			     [C#chunk { idt = {Id, Index, {assigned, Pid}} }]),
  		  C#chunk.chunk
  	      end || C <- Return],
      {ok, {Index, Chunks}, length(Return)}.
  
  %% Check the piece Idx on torrent Id for completion
  check_piece(FSPid, Id, Idx) ->
      etorrent_fs:check_piece(FSPid, Idx),
  
negative.code:     etorrent_torrent:decrease_not_fetched(Id),
      ok.
  
  %% @doc Search for piece chunks to download from a peer
  %%   We are given an iterator of the pieces the peer has. We search the
  %%   the iterator for a pieces we have already chunked and are downloading.
  %%   If found, return the #chunk{} object. Otherwise return 'none'
  %% @end
  -spec find_chunked_chunks(pos_integer(), term(), A) -> A | [#chunk{}].
  find_chunked_chunks(_Id, none, Res) -> Res;
  find_chunked_chunks(Id, {Pn, Next}, Res) ->
      case etorrent_piece_mgr:is_chunked(Id, Pn) of
  