Major cleanup before formatting