Fix bug where text was duplicated in some rare cases.