Changed the way random numbers are generated.