Fixed: A few memory leaks and cases of uninitialized data caught by Valgrind.