Added modular arithmetic code.