   clear: ->
     [observable_records, @observable_records] = [@observable_records, {}]
     for creator, records of observable_records
-      kb.release(record.observable) for record in records
+      kb.release(observable) for cid, observable of records
 
     [replaced_observables, @replaced_observables] = [@replaced_observables, []]
     kb.release(replaced_observables)


  # Manually compact the store by searching for released view models
  compact: ->
    # TODO: optimize
    for creator, records of @observable_records
      removals = []
      removals.push(record) for record in records when record.observable?.__kb_released
      @observable_records[creator] = _.difference(records, removals) if removals.length
    return

  # Used to register a new view model with the store.

  #   kb.Store.useOptionsOrCreate(model, this, options);
  @useOptionsOrCreate: (options, obj, observable) ->
    if options.store
      creator = options.factory.creatorForPath(obj, options.path) if (options.path and options.factory)
      options.store.register(obj, observable, creator)
      return kb.utils.wrappedStore(observable, options.store)
    else
      kb.utils.wrappedStoreIsOwned(observable, true)
