Fix use of RNG functions to be hopefully consistent cross-platform