Bug fixes to text and entity