Rework cleanup code to be more consistient.