trying to fix memory leaks.