Fixing global var leak