Added additional bound checks to RNG.