fixes memleadks reported by valgrind