   init() {
     // TODO: clean this up
     let app = Application.allForBundleID("com.apple.finder").first!
-    print("app attrs: \(try! app.attributes())")
-    let observer = app.createObserver() { (observer, element, notification) in
-      if notification == .WindowCreated {
-        let window = try! OSXWindow(state: self, axElement: element, observer: observer)
-        self.windows.append(window)
-        self.notify(.WindowCreated, event: WindowEvent(window: window, external: true))
-      } else if let (index, target) = self.findWindowAndIndex(element) {
-        if notification == .UIElementDestroyed {
-          self.windows.removeAtIndex(index)
-          self.notify(.WindowDestroyed, event: WindowEvent(window: target, external: true))
-        }
-        target.onEvent(observer, event: notification)
-      } else {
-        print("Event \(notification) on unknown element \(element)")
-      }
-    }!
+    let observer = app.createObserver(handleEvent)!
     try! observer.addNotification(.WindowCreated,     forElement: app)
     try! observer.addNotification(.MainWindowChanged, forElement: app)
     observer.start()

    observers.append(observer)
  }

  var visibleWindows: [Window] {
    get { return windows }
  }

  private func findWindowAndIndex(axElement: UIElement) -> (Int, OSXWindow)? {
    return self.windows.enumerate().filter({ $0.1.axElement == axElement }).first
  }

  private typealias EventHandler = (Event) -> ()

      fatalError("unhandled error: \(error)")
    }
  }
}
