Avoid some rational overflow

This change avoids overflow for rational +, -, rem, mod in certain situations where the denominators are large but have significant common divisors. An important special case is when both rationals have the same denominator.

The same technique is also applied to integer lcm.