fixed valgrind issues