User MersenneTwister to generate random values. Fix compile errors.