Removing dead code, fixing RNG generation