anchor.diff:          false ->
               error(badarg);
           true ->
  -            Intersection = Elements0 band Elements1,
  +            PaddingLen = paddinglen(Size0),
  +            <<E0:Size0, 0:PaddingLen>> = Elements0,
  +            <<E1:Size0, 0:PaddingLen>> = Elements1,
  +            Shared = E0 band E1,
  +            Intersection = <<Shared:Size0, 0:PaddingLen>>,
               #pieceset{size=Size0, elements=Intersection}
       end.
  -    
  -    
  -
  -piecemask(PieceIndex, Size) ->
  -    1 bsl (Size - PieceIndex - 1).
   
   paddinglen(Size) ->
       Length = 8 - (Size rem 8),
  
positive.code:         false ->
              error(badarg);
          true ->
              NewElements = Elements bor piecemask(PieceIndex, Size),
              Pieceset#pieceset{elements=NewElements}
      end.
  
  %% @doc
  
negative.code: %% @end
  from_binary(Bin, Size) when is_binary(Bin) ->
      PaddingLen = paddinglen(Size),
      <<_:Size, PaddingValue:PaddingLen>> = Bin,
      %% All bits used for padding must be set to 0
      case PaddingValue of
          0 -> ok;
          _ -> error(badarg)
      end,
      #pieceset{size=Size, elements=Bin}.
  
  %% @doc
  %% Convert a piece set to a bitfield, the bitfield will
  %% be padded with at most 7 bits set to zero.
  %% @end
  to_binary(Pieceset) ->
      #pieceset{elements=Elements} = Pieceset,
      Elements.
  
  %% @doc
  %% Returns true if the piece is a member of the piece set,
  