Check if cursor is null.
Fixes #47