Cosmetics
Refactor iter_tasks and get_task_by_id