deal with memory leaks