Refactored division and modulo (refs #191).