Improving cleanup routines on deactivation.