refactor out common cleanup tasks
Reuse common cleanup include