Fixed valgrind warnings