anchor.diff:              case ets:lookup(?TAB, {Id, Pn, not_fetched}) of
                   [] ->
                       find_chunked_chunks(Id, gb_sets:next(Next), found_chunked);
  -                _ ->
  -                    Pn
  +                Objects ->
  +                    Objects
               end;
           false ->
               find_chunked_chunks(Id, gb_sets:next(Next), Res)
  
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:             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})
      end;
  
  