fix length check
Merge partial fix of a unicode processing crash.
Refactor fixed cursorx_to_position() function to not duplicate code.
Add braces while I'm at it.