Improve cursor movements around edgecases