Fixed improperly created cursors when there are several reference fields.