     console.log "Stacker.Card#fromJSON", data
     stackId = data.stackId
     data.stackId = undefined
-    data.stack = repository.get(stackId)
+    stack = data.stack = repository.get(stackId) || Stacker.alloc(Stacker.Cards, [], id:stackId)
     card = Stacker.alloc Stacker.Card, data
     Stacker.updateCardFromHtml(card, data.html)
+    stack.add card
     card
 
   toJSON: ->

    options.history ||= window.history
    options.storage ||= window.sessionStorage
    
    @networkController = Stacker.NetworkController
    @historyStack = Stacker.alloc(Stacker.Cards)
    @historyController = new Stacker.HistoryController(
      @historyStack, options.history, options.storage

window.Stacker = {}

Stacker.Repo = new Backbone.Collection
Stacker.alloc = (klass, args...) -> @Repo.add item = new klass(args...); item
Stacker.get = (id) -> @Repo.get(id)
Stacker.flush = -> @Repo.set [], silent:true

