Reduced code duplication in NumberGen.