         pane.activateItem(this)
 
     if @file?
-      @subscribe @file.onDidChange(changeHandler)
-    else if @editor?
-      @subscribe @editor.getBuffer().onDidStopChanging =>
+      @disposables.add @file.onDidChange(changeHandler)
+    else if @editor?
+      @disposables.add @editor.getBuffer().onDidStopChanging =>
         changeHandler() if atom.config.get 'markdown-preview.liveUpdate'
-      @subscribe @editor.onDidChangePath => @trigger 'title-changed'
-      @subscribe @editor.getBuffer().onDidSave =>
+      @disposables.add @editor.onDidChangePath => @trigger 'title-changed'
+      @disposables.add @editor.getBuffer().onDidSave =>
         changeHandler() unless atom.config.get 'markdown-preview.liveUpdate'
-      @subscribe @editor.getBuffer().onDidReload =>
+      @disposables.add @editor.getBuffer().onDidReload =>
         changeHandler() unless atom.config.get 'markdown-preview.liveUpdate'
 
-    @subscribe atom.config.onDidChange 'markdown-preview.breakOnSingleNewline', changeHandler
+    @disposables.add atom.config.onDidChange 'markdown-preview.breakOnSingleNewline', changeHandler
 
   renderMarkdown: ->
     @showLoading()

    if atom.workspace? and atom.workspaceView?
      resolve()
    else
      @subscribe atom.packages.onDidActivateAll(resolve)

  editorForId: (editorId) ->
    for editor in atom.workspace.getTextEditors()

  constructor: ({@editorId, @filePath}) ->
    super

    @disposables = new CompositeDisposable

    unless @editorId?
      if atom.workspace?
        @subscribeToFilePath(@filePath)
      else
        @disposables.add atom.packages.onDidActivateAll =>
          @subscribeToFilePath(@filePath)

  afterAttach: ->
    return if @attached

    @attached = true
    if @editorId?
      @resolveEditor(@editorId)

  beforeRemove: ->
    @attached = false
