Removed few unused variables and fixed random value gen bugs