       images[id].count -= 1
 
 historify = (x) -> () ->
-  history = Template.instance().history.get()
+  history = messageHistory.get @_id
   if history?
     history[x]
   else

    #  e.dataTransfer.setData 'text/plain', "<IMG SRC='#{url}'>"

  ## Fold deleted messages by default on initial load.
  @folded.set true if @data.deleted
  #@$.children('.panel').children('.panel-body').find('a[href|="/gridfs/fs/"]')
  #console.log @$ 'a[href|="/gridfs/fs/"]'
  template = @
  id2template[@data._id] = template
  scrollToMessage @data._id if scrollToLater == @data._id
  attachment = @data.format == 'file'
  #images = Session.get 'images'

  'click .historyButton': (e, t) ->
    e.preventDefault()
    e.stopPropagation()
    if messageHistory.get(@_id)?
      messageHistory.set @_id, null
    else
      messageHistory.set @_id, _.clone @

  'click .superdeleteButton': (e) ->
    e.preventDefault()
