fix valgrind issues