Fixed all Valgrind warnings