minor tweaks to random number generator