Fix global variable leak