         template: Handlebars.compile $('#machine_list-template').html()
 
         initialize: (datacenter_uuid) ->
+            @datacenter_uuid = datacenter_uuid
             @callbacks = []
             super machines, ServerView.MachineListElement, 'tbody.list',
-                filter: (model) -> model.get('datacenter_uuid') is datacenter_uuid
-
-            machines.on 'change:datacenter_uuid', (machine, new_datacenter_uuid) =>
-                num_elements_removed = @remove_elements machine
-                @render() if num_elements_removed > 0
-
-                if new_datacenter_uuid is datacenter_uuid
-                    @add_element machine
-                    @render()
-
+                filter: (model) -> model.get('datacenter_uuid') is @datacenter_uuid
+
+            machines.on 'change:datacenter_uuid', @changed_datacenter
             return @
+
+        changed_datacenter: (machine, new_datacenter_uuid) =>
+            num_elements_removed = @remove_elements machine
+            @render() if num_elements_removed > 0
+
+            if new_datacenter_uuid is @datacenter_uuid
+                @add_element machine
+                @render()
 
 
         add_element: (element) =>

            $(event.currentTarget).tooltip('show')

        destroy: =>
            @model.off()
            directory.off()

    # Datacenter list element
    class @DatacenterListElement extends UIComponents.CollapsibleListElement

            @bind_callbacks_to_machine machine_list_element for machine_list_element in @element_views

        bind_callbacks_to_machine: (machine_list_element) =>
            machine_list_element.off 'selected', @call_all_callback
            machine_list_element.on 'selected', @call_all_callback

        call_all_callback: =>
            callback() for callback in @callbacks

        destroy: ->
            machines.off 'change:datacenter_uuid', @changed_datacenter


    # Machine list element
