Fixed valgrind errors.