Added PRNG for producing test data.
Minor optimization.