trying to clean up memory leaks