Memory leak improvement