Fixed bugs resulting from the switch to RichTextCtrl