Attempt to fix memory leaks.