fix some bugs with SafeLong and Rational