fixed broken cleanup routines