Ensure buffer sizes are powers of two, use masking instead of modulo.