Would this be more correct if the move the `drainXXX()` calls to before the while loop?