Fix leaks in popup