Improved destructor/finalizer handling