Fixed a bug in random number generation.