Extract cleanUp() method.