Fixed bugs with text editor