Rewrote the randomgenerator.