Updated flush mechanism to exclusively flush and not queue next flush until finished