Added random generation code.