Fix possible NPE

seems cursor could be null under some conditions at bootup