Used the wrong denominator in several modulus function. Corrected all
instances of this mistake