   scrollToMessage @data._id if scrollToLater == @data._id
   #images = Session.get 'images'
   @images = {}
+  @imagesInternal = {}
   initImage @data._id
-  images[@data._id].file = @data.file
+  ## initImage calls updateFileQuery which will do this:
+  #images[@data._id].file = @data.file
+  #initImageInternal @data.file if @data.file?
   @autorun =>
     data = Template.currentData()
     ## If message is naturally folded, don't count images it references.

      file: null
    updateFileQuery()

checkImage = (id) ->
  return unless id of images
  ## Image gets unnaturally folded if it's referenced at least once.
  messageFolded.set id, (images[id].count > 0) or images[id].naturallyFolded
  ## No longer care about this image if it's not referenced and doesn't have
  ## a rendered template.
  if images[id].count == 0 and id not of id2template
    delete images[id]
    updateFileQuery()

messageDrag = (target, bodyToo = true) ->
  return unless target

        images[id].count -= 1
        checkImage id
      @images = {}
      for id of @imagesInternal
        imagesInternal[id].count -= 1
        checkImageInternal id
      @imagesInternal = {}
    else
      newImages = {}
      body = $($.parseHTML("<div>#{formatBody data.format, data.body}</div>"))
      body.find 'img[src^="/file/"]'
      .each ->
        newImages[url2file @getAttribute('src')] = true
      newImagesInternal = {}
      body.find 'img[src^="/gridfs/"]'
      .each ->
        newImagesInternal[url2internalFile @getAttribute('src')] = true
      for id of @images
        unless id of newImages
          images[id].count -= 1
