Improved random number generation. Seed was not read if given