                         data.num_live_namespaces++
                     data.nshards += namespace_status.nshards
                     data.nreplicas += data.nshards + namespace_status.nreplicas
+                    # We should use _.uniq on the datacenters for all the tables, not on each table
                     data.ndatacenters += namespace_status.ndatacenters
 
+            # We update only if the data has changed
             if not _.isEqual @data, data
                 @data = data
                 @.$el.html @template data
 
             return @
 
+        # Unbind listeners
         destroy: =>
             namespaces.off 'all', @render
 


            return @

        close_alert: (event) ->
            event.preventDefault()
            $(event.currentTarget).parent().slideUp('fast', -> $(this).remove())

        rename_database: (event) =>
            event.preventDefault()
            rename_modal = new UIComponents.RenameItemModal @model.get('id'), 'database'
            rename_modal.render()

        delete_database: (event) ->
            event.preventDefault()
            remove_database_dialog = new DatabaseView.RemoveDatabaseModal
            remove_database_dialog.render @model

        destroy: =>
            @title.destroy()
            @profile.destroy()
            @performance_graph.destroy()

# Database view
module 'DatabaseView', ->
    # Class in case the database is not found (propably a deleted database). Links to this view can be found in old logs.
    class @NotFound extends Backbone.View
        className: 'section'
        template: Handlebars.compile $('#element_view-not_found-template').html()
        initialize: (id) =>
            @id = id

        render: =>
            @.$el.html @template
                id: @id
                type: 'database'
                type_url: 'databases' # Use to build a url to a specific database
                type_all_url: 'tables' # Use to build a url to the list of all databases
            return @

    # Container for the entire database view
