         name = name + "2"
     @id = "pages_" + name
     @name = name
+  
+  #
+  
   registerInstance: ->
     Pages::_ninstances++
     Pages::instances[@name] = @
+  
+  # Set the collection on which this instance operates. Creates a new one if a name is passed in.
+  
   setCollection: (collection) ->
     if typeof collection is 'object'
       Pages::collections[collection._name] = collection

        @init = false    
    @sess "oldPage", @initPage
    @sess "currentPage", @initPage
  getPage: (page) ->
    if Meteor.isClient
      page = @currentPage()  unless page?

          @sess "currentPage", 1
      ).bind(@)
    , 500
    
  publishNone: ->
    @ready()
    return @Collection.find null
  
  # Called from the Meteor.publish call made during init, this Publishes the paginated collection
  #
  # "this" will be the pagination instance
  # "page" is the page number to publish
  # "sub" is the publish handler object which (the "this" object when the function passed to Meteor.publish is called)
  
  publish: (page, sub) ->
    check page, Number
    check sub, Match.Where (s) ->
      s.ready?
    cid = sub.connection.id
    
    # Create get and set functions for this specific connection (the settings will end up in the @userSettings,
    # stored in an object indexed under the collection id)
    
    get = sub.get = ((cid, k) -> @get k, cid).bind(@, cid)
    set = sub.set = ((cid, k, v) -> @set k, v, cid: cid).bind(@, cid)
    
    # If there are already filters set up for this connection id, clear them (is this right?)
    
    delete @userSettings[cid]?.realFilters
    delete @userSettings[cid]?.nPublishedPages
    
    @setPerPage()
    skip = (page - 1) * get "perPage"
    skip = 0 if skip < 0
    filters = get "filters"
    options = 
      sort: get "sort"
      fields: get "fields"
      skip: skip
      limit: get "perPage"
    
    # Call the authentication function if it's supplied
    
    if @auth?
      r = @auth.call @, skip, sub
      if !r
