       phase.get('tasks').addObject(task)
     if action == 'updated' && phase != oldPhase
       phase.get('tasks').addObject(task)
-      oldPhase.get('tasks').removeObject(oldTask)
+      oldPhase.get('tasks').removeObject(oldTask) if oldPhase
       task.set('phase', phase)
 
     task.triggerLater('didLoad')

        return if data.enabled == 'false'
        @set('eventSource', new EventSource(data.url))
        Ember.$(window).unload => @stop()
        data.eventNames.forEach (eventName) =>
          @addEventListener(eventName)
    Ember.$.ajax(params)

  msgResponse: (msg) ->
    esData = JSON.parse(msg.data)
    action = esData.action
    meta = esData.meta
    delete esData.meta


  processMessages: ->
    unless @get('wait')
      if msg = @messageQueue.popObject()
        msg.data = JSON.parse(msg.data)
        if @shouldProcessMessage(msg)
          @msgResponse(msg.data)
    Ember.run.later(@, 'processMessages', [], interval)

  shouldProcessMessage: (msg) ->
    @get('eventNames').contains(msg.type) or msg.data.action == 'destroyed'

  pause: ->
    @set('wait', true)
