Changes to task scheduling to fix race conditions and (apparent via testing) duplicate tasks