Modifications to improve the modular arithmetic and remove the need for the ugly type wrappers.