Fix leaking global bug