Attempted to improve cursor setting logic.