Fix cursor deref bug