Fix a few small leaks caught by valgrind.