   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.

  .observeChanges
    added: (id, fields) ->
      images[id].file = fields.file
    changed: (id, fields) ->
      if fields.file? and images[id].file != fields.file
        forceImgReload urlToFile id
        images[id].file = fields.file

initImage = (id) ->
  if id not of images

        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
