Fix byte_count calculation in case of flushes