improve CleanupCode