Fix leaking global variables

All in the title :-)