Improve handling of tasks