Inline doNextWrite into advanceQueue
Port to spec