Fix memory leaks. Still some exist, but they can wait.