Refactoring

- replaced .caret() calls with getCaretPos/setCaretPos where possible
- replaced all .val() calls with getValue/setValue
- refactored smart caret positioning code