Remove obsolete code
Fix expandToVisibleCharacter() to reach end of text node with trailing
characters.
Refactor next/prev position code