All routines were modified similarily: put the Rational test first for quick response for Rationals, then put the nan test last.