Fix to remove tasks not in task tree