Reuse flush() and set ByteBuffer position correctly after flushing