     Session.set 'currentPublicationProgress', documentHalf + pagesHalf
 
   show: =>
-    @destroy()
+    console.debug "Showing publication #{ @_id }"
+
+    assert.strictEqual @_pages, null
 
     @_pagesDone = 0
     @_pages = []
 
-    # TODO: Handle errors as well
     PDFJS.getDocument(@url(), null, null, @_progressCallback).then (@_pdf) =>
+      # To make sure we are starting with empty slate
+      $('#viewer .display-wrapper').empty()
+
       for pageNumber in [1..@_pdf.numPages]
         $canvas = $('<canvas/>').addClass('display-canvas').addClass('display-canvas-loading')
         $loading = $('<div/>').addClass('loading').text("Page #{ pageNumber }")
-        $pageDisplay = $('<div/>').addClass('display-page').append($canvas).append($loading).appendTo('#viewer .display-wrapper')
-
-        do ($canvas, $pageDisplay) =>
-          # TODO: Handle errors as well
+        $('<div/>').addClass('display-page').attr('id', "display-page-#{ pageNumber }").append($canvas).append($loading).appendTo('#viewer .display-wrapper')
+
+        do (pageNumber) =>
           @_pdf.getPage(pageNumber).then (page) =>
+            # Maybe this instance has been destroyed in meantime
+            return if @_pages is null
+
+            assert.equal pageNumber, page.pageNumber
+
             viewport = @_viewport
               page: page # Dummy page object
 
+            $canvas = $("#display-page-#{ pageNumber } canvas")
             $canvas.removeClass('display-canvas-loading').attr
               height: viewport.height
               width: viewport.width
 
-            @_pages[page.pageNumber - 1] =
-              $canvas: $canvas
-              $pageDisplay: $pageDisplay
+            @_pages[pageNumber - 1] =
+              pageNumber: pageNumber
               page: page
               rendering: false
             @_pagesDone++

    Meteor.subscribe 'annotations-by-publication', Session.get 'currentPublicationId'

Deps.autorun ->
  publication = Publications.findOne Session.get 'currentPublicationId'

  return unless publication


class @Publication extends @Publication
  constructor: (args...) ->
    super args...

    @_pages = null

  _viewport: (page) =>
    scale = 1.25
    page.page.getViewport scale

  _progressCallback: (progressData) =>
    # Maybe this instance has been destroyed in meantime
    return if @_pages is null

    @_progressData = progressData if progressData

    documentHalf = _.min [(@_progressData.loaded / @_progressData.total) / 2, 0.5]
