Second commit for smart cursor. To be abandoned.