destructor call and some cleanup