Changed modulus operators to simple bit manipulations.