Better cursor position restoration.