Improved cleanup routines