Improvements to DIGITS and NTH-DIGIT.

Thanks to stassats.