Improved performance of cleanup command.