Fix random number generation.