Fix remaining valgrind issues