fix some valgrind warnings, memory leaks