Refactoring random number functions.