Solves problem when pressing arrow up/down and the screen did not scroll up/down. Also fix some issues when setting the caret in the right position. Pressing up/down went into the beginning of the paragraph instead of the paragraph below or above.