Move relevant parts of DSU cleanup code to base