Fixed some valgrind warnings.