fix more issues with integer conversion in random number generation