bugfix. updating the last_flushed_segment_id at the wrong line. And, add comments