Improved random generation.