fix for cursor bug/forced disconnect

undefined breaking stuff, as usual