Fix up cursor code