 Zotero.BetterBibTeX.itemAdded = {
   notify: (event, type, collection_items) ->
     Zotero.BetterBibTeX.log('::: itemAdded', event, type, collection_items)
-    return unless event == 'add'
-
+
+    collections = []
     for collection_item in collection_items
       [collectionID, itemID] = collection_item.split('-')
       Zotero.BetterBibTeX.log('::: itemAdded', collectionID, itemID)
-
+      collections.push(collectionID)
+
+      # aux-scanner only triggers on add
+      continue unless event == 'add'
       collection = Zotero.Collections.get(collectionID)
-      Zotero.BetterBibTeX.log('::: itemAdded collection = ', collection?.id)
       continue unless collection
 
       extra = Zotero.DB.valueQuery("#{Zotero.BetterBibTeX.findExtra} and i.itemID = ?", [itemID])
-      Zotero.BetterBibTeX.log('::: itemAdded extra = ', extra)
       continue unless extra
 
       try


  nids = []
  nids.push(Zotero.Notifier.registerObserver(@itemChanged, ['item']))
  nids.push(Zotero.Notifier.registerObserver(@itemAdded, ['collection-item']))
  window.addEventListener('unload', ((e) -> Zotero.Notifier.unregisterObserver(id) for id in nids), false)

  uninstaller = {
    onUninstalling: (addon, needsRestart) ->

  @formatters[pattern] = BetterBibTeXFormatter.parse(pattern) unless @formatters[pattern]
  return @formatters[pattern]

Zotero.BetterBibTeX.idleService = Components.classes["@mozilla.org/widget/idleservice;1"].getService(Components.interfaces.nsIIdleService)
Zotero.BetterBibTeX.idleObserver = observe: (subject, topic, data) ->
  switch topic
    when 'idle'
      Zotero.BetterBibTeX.auto.idle = true
      Zotero.BetterBibTeX.auto.process('idle')

    when 'back'
      Zotero.BetterBibTeX.auto.idle = false
  return

Zotero.BetterBibTeX.init = ->
  @log("Running init: #{@initialized}")
  return if @initialized
