Fixed all valgrind errors.