   }))())
   .done () ->
     $(".problem-state").bootstrapSwitch()
+    problemStateChanges()
+
+areChangesEqual = (a, b) ->
+  a.target == b.target and a.type == b.type
 
 setupQueueFrame = ->
   $("#main-content").prepend """

    $.when getProblemData()
      .done (() ->
        console.log "Updating"
        $(this).trigger "makeChange"
        $("#problem-list").trigger "filterUpdate"
      ).bind this

  $("#main-content>.container").addClass("col-md-10")

problemStateChanges = ->
  $(".problem-state").on "switchChange.bootstrapSwitch", (e, state) ->
    pid = $(e.target).attr "id"
    problem = window.data.problems[pid]
    change = {

      data: {original: !state, change: state}
      display: (if state then "Enabling" else "Disabling") + " " + problem.name  + " for the competition."
      shouldAdd: (changes) -> _.all (_.map changes, (change) ->
        !(areChangesEqual change, {target: problem.name, type: "availability"}))
      process: () ->
        apiCall "POST", "/api/admin/problems/availability", {pid: problem.pid, state: state}
    }

    change.shouldRemove = (changes) -> _.filter changes, _.partial areChangesEqual, change

    $("#problem-update-queue").trigger "makeChange", [change]

