anchor.diff:                  pieces_stored=NewStored,
                   pieces_valid=NewValid},
               {reply, ok, NewState}
  -    end;
  -
  -handle_call({mark_fetched, _Pid, _Index, _Offset, _Length}, _, State) ->
  -    %% If we are in endgame mode, requests for a chunk may have been
  -    %% sent to more than one peer. Return a boolean indicating if the
  -    %% peer was the first one to mark this chunk as fetched.
  -    {reply, {ok, true}, State};
  -
  -handle_call({mark_stored, Pid, Index, Offset, Length}, _, State) ->
  -    %% The calling process has written this chunk to disk.
  -    %% Remove it from the list of open requests of the peer.
  +    end.
  +
  +
  +%% @private
  +%% If we receive a notification about a stored chunk there are three
  +%% possible cases that we must consider in order to handle it correctly.
  +%% 
  +%% 1. This process is the assigning process
  +%% 2. The notifictation comes from a peer has not received the new process
  +%% 3. The notification comes from the new assigning process
  +%%
  +%% Case #1 and #3 are handled the same way. Case #2 must be forwarded
  +%% to the new assigning process unmodified. If it practially guarantees
  +%% that the chunk will be fetched twice. In this case we don't bother
  +%% to handle it because we expect the assigning process to send copies
  +%% of these notifications to this process.
  +%%
  +handle_info({chunk, {stored, Piece, Offset, Length, Peerpid}}, State)
  +when ?in_endgame(State) and not ?is_assigning(State, Peerpid) ->
  +    #state{assigning=Assigning} = State,
  +    ok = etorrent_chunkstate:stored(Piece, Offset, Length, Peerpid, Assigning),
  +    {noreply, State};
  +
  +handle_info({chunk, {stored, Index, Offset, Length, _}}, State) ->
       #state{
           torrent_pid=TorrentPid,
           pieces_assigned=Assigned,
           pieces_stored=Stored,
  -        peer_monitors=Peers,
           chunks_stored=ChunksStored} = State,
  -    OpenReqs = etorrent_monitorset:fetch(Pid, Peers),
  -    NewReqs  = gb_trees:delete({Index, Offset}, OpenReqs),
  -    NewPeers = etorrent_monitorset:update(Pid, NewReqs, Peers),
  +
       %% Update the set of chunks in the piece that has been written to disk.
       Chunks = array:get(Index, ChunksStored),
       NewChunks = etorrent_chunkset:delete(Offset, Length, Chunks),
  
positive.code: -import(erlang, [monitor/2, error/1]).
  
  -type pieceset()   :: etorrent_pieceset:pieceset().
  -type monitorset() :: etorrent_monitorset:monitorset().
  -type torrent_id() :: etorrent_types:torrent_id().
  -type chunk_len() :: etorrent_types:chunk_len().
  -type chunk_offset() :: etorrent_types:chunk_offset().
  
negative.code: %% @doc
  %% Mark a piece as completly stored to disk and validated.
  %% @end
  -spec mark_valid(pos_integer(), pid()) -> ok.
  mark_valid(Piece, SrvPid) ->
      SrvPid ! {mark_valid, Piece},
      ok.
  
  
  %% @doc
  %% Request a unique set of chunks from the server.
  %% @end
  -spec request_chunks(torrent_id(), pieceset(), pos_integer()) ->
      {ok, list({piece_index(), chunk_offset(), chunk_len()})}
  