Minor bugs in text highlighting and on opening a new doc fixed