fix a global variable leak