Fix leaked global vars