     else
       @sourceCollection.remove selector
 
-  setupTargetObservers: =>
-    referenceFields =
-      _id: 1 # In the case we want only id, that is, detect deletions
-    for field in @fields
-      referenceFields[field] = 1
-
-    @targetCollection.find({}, fields: referenceFields).observeChanges
-      added: (id, fields) =>
-        @_updateSource id, fields
-
-      changed: (id, fields) =>
-        @_updateSource id, fields
-
-      removed: (id) =>
-        @_removeSource id
-
   updatedWithValue: (id, value) =>
     unless _.isObject(value) and _.isString(value._id)
       # Special case: when elements are being deleted from the array they are temporary set to null value, so we are ignoring this


    @sourceCollection.update selector, update, multi: true

  _removeSource: (id) =>
    selector = {}
    selector["#{ @sourcePath }._id"] = id


Document._TargetedFieldsObservingField = class extends Document._TargetedFieldsObservingField
  setupTargetObservers: =>
    referenceFields =
      _id: 1 # In the case we want only id, that is, detect deletions
    for field in @fields
      referenceFields[field] = 1

    @targetCollection.find({}, fields: referenceFields).observeChanges
      added: (id, fields) =>
        @updateSource id, fields

      changed: (id, fields) =>
        @updateSource id, fields

      removed: (id) =>
        @removeSource id

# Refresh ReferenceField.prototype with new TargetedFieldsObservingField
_.extend Document._ReferenceField.prototype, Document._TargetedFieldsObservingField.prototype, Document._ReferenceField.prototype

Document._ReferenceField = class extends Document._ReferenceField
  updateSource: (id, fields) =>
    # Just to be sure
    return if _.isEmpty fields

