anchor.diff:  		   S#state.parent,
   		   Rate#peer_rate.rate,
   		   Amount),
  -	    {noreply, S#state { rate = Rate}, Timeout};
  -	{{error, ebadf}, R, _Amount} ->
  -	    error_logger:info_report([caught_ebadf, S#state.socket]),
  -	    {stop, normal, S#state { rate = R}};
  -	{{error, closed}, R, _Amount} ->
  -	    {stop, normal, S#state { rate = R}}
  -    end.
  +	    {ok, S#state { rate = Rate}};
  +	{{error, E}, R, _Amount} ->
  +	    {error, E, S#state { rate = R }}
  +    end.
  +
  +
  +perform_choke(S = #state { fast_extension = FX, choke = C}) ->
  +    case {FX, C} of
  +	{false, true} -> {noreply, S, 0};
  +	{false, false} ->
  +	    ok = local_choke(S),
  +	    send_message(choke, S#state{choke = true, piece_cache = none});
  +	{true, true} -> {noreply, S, 0};
  +	{true, false} ->
  +	    local_choke(S),
  +	    {ok, NS} = send(choke, S),
  +	    FS = empty_piece_cache(NS),
  +	    {noreply, FS, 0}
  +    end.
  +
  +
  +empty_piece_cache(S) ->
  +    empty_piece_cache(S#state.piece_cache, S).
  +
  +empty_piece_cache([], S) ->
  +    S#state { piece_cache = [] };
  +empty_piece_cache([{Index, Offset, Len} | Next], S) ->
  +    {ok, NS} = send({reject_request, Index, Offset, Len}, S),
  +    empty_piece_cache(Next, NS).
  +
  +local_choke(S) ->
  +    etorrent_rate_mgr:local_choke(S#state.torrent_id,
  +				  S#state.parent).
  
positive.code:     error_logger:info_report([got_unknown_message, Msg, S]),
      {stop, {unknown_msg, Msg}}.
  
  handle_cast(choke, S) when S#state.choke == true ->
      {noreply, S, 0};
  handle_cast(choke, S) when S#state.choke == false ->
      ok = etorrent_rate_mgr:local_choke(S#state.torrent_id, S#state.parent),
      send_message(choke, S#state{choke = true, piece_cache = none});
  handle_cast(unchoke, S) when S#state.choke == false ->
      {noreply, S, 0};
  handle_cast(unchoke, S) when S#state.choke == true ->
  
negative.code:     send_message(Msg, S, 0).
  
  send_message(Msg, S, Timeout) ->
      case send(Msg, S) of
  	{ok, NS} -> {noreply, NS, Timeout};
  	{error, closed, NS} -> {stop, normal, NS};
  	{error, ebadf, NS} -> {stop, normal, NS}
      end.
  
  send(Msg, S) ->
      case etorrent_peer_communication:send_message(S#state.rate, S#state.socket, Msg) of
  	{ok, Rate, Amount} ->
  	    ok = etorrent_rate_mgr:send_rate(
  