Changed the way cursor movement is handled