Mersenne twister implementation