Rewrote SelectionState for multiline-text support + some little changes