Improved destructor code.