flush and isFlushNeeded functions made public