Fix bug when deleting a task (ConcurrentModificationException)