Fix refcount bug in Environment.cursor().