Fix single ratio generation with numerators or denominators greater than 9. Tidy up source a bit.