fix leaking globals