Refactored cleanup command