Memory leak fix