Task Queue Compacting and Task Ordering

TBA...
The above chunk of code was moved from below without changes.