reorder some of the cleanup routines, cleanup (experimental)