Added support for handling caret position.