Fix potential reference leak