Merge pull request #2369 from vlakoff/develop-2

Some cleanup related to mt_rand()