       AND item.itemTypeID NOT IN (#{@query.type.attachment}, #{@query.type.note})
     """)
     for item in items
+      ids.push(item.itemID)
       # if no citekey is found, it will be '', which will allow it to be found right after this loop
       citekey = Citekey.get(item.extra)
       debug('KeyManager.rescan:', {itemID: item.itemID, citekey})

      else
        debug('KeyManager.rescan: clearing citekey for', item.itemID)
        @keys.insert(Object.assign(citekey, { itemID: item.itemID, libraryID: item.libraryID }))

    # find all references without citekey
    @scanning = @keys.find({ citekey: '' })

#      @keys.findAndRemove({ citekey: '' }) # how did empty keys get into the DB?!
    debug('KeyManager.rescan:', {clean, keys: @keys})

    ids = []
    items = yield Zotero.DB.queryAsync("""
      SELECT item.itemID, item.libraryID, extra.value as extra, item.itemTypeID
      FROM items item
