Fixed bug related to incorrect MAX in Random.rand