more code clearance, global vars fix