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});
  -	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),
  -                                       [{PieceNum, Chunks} | SoFar],
  -                                       Remaining - Size, Res})
  +	PN when is_integer(PN) ->
  +	    case select_chunks_by_piecenum({Id, PN}, Remaining) of
  +		{ok, {PieceNum, Chunks}, Size} ->
  +		    pick_chunks(pick_chunked, {Pid, Id,
  +					       gb_sets:del_element(PieceNum, PieceSet),
  +					       [{PieceNum, Chunks} | SoFar],
  +					       Remaining - Size, Res});
  +		{error, already_taken} ->
  +		    %% So somebody else took this, try again
  +		    pick_chunks(pick_chunked, {Pid, Id, PieceSet, SoFar, Remaining, Res})
  +	    end
       end;
   
   %%
  
positive.code:         none_eligible ->
              {ok, SoFar}
      end;
  %%
  %% Handle the endgame for a torrent gracefully
  pick_chunks(endgame, {Id, PieceSet, N}) ->
  
negative.code: -spec new(integer()) -> ok.
  new(Id) ->
      gen_server:call(?SERVER, {new, Id}).
  
  %% ----------------------------------------------------------------------
  
  %% @doc Choose up to Max chunks from Selected.
  %%  Will return {ok, {Index, Chunks}, size(Chunks)}.
  %% @end
  -spec select_chunks_by_piecenum({pos_integer(), pos_integer()}, pos_integer()) ->
  			   {ok, {pos_integer(), term()}, non_neg_integer()} | {error, already_taken}.
  select_chunks_by_piecenum({TorrentId, Pn}, Max) ->
      gen_server:call(?SERVER, {select_chunks_by_piecenum, {TorrentId, Pn}, Max}).
  
  
  %%====================================================================
  %% gen_server callbacks
  