fix destructor memory cleanup