Improved the optimize task.