Handle memory leaks