Got rid of memory leaks.