Looking at the timeout issues and random number generator
Fixed up some code style