Tweaked the way recordState() is called from runTasks().