Adds --max_tasks option to limit the number of tasks in memory