Made the cursor-changing code more robust