Minor fixes

fixed random number generator
cleaned table generation code