Fix a random number generation issue and the case for zero index found when doing binary search.