Improved randomgen.