Optimize random number generation slightly.