Do cleanup work in an earlier stage to ensure correct conf saving.