Move flushTaskInProgress to AbstractUnsafe

.. because it's referenced only there.  Also did tiny optimizations.