Fixes random number generation errors