More memory leak fixes - Valgrind now reports 0 bytes lost when running test.c