     public func evaluateJavaScript(string: String, completionHandler: ((AnyObject!, NSError!)->Void)?) {
         // TODO: Should call completionHandler with an NSError object when webView is nil
         if NSThread.isMainThread() {
-            _webView.evaluateJavaScript(string, completionHandler: completionHandler)
+            webView.evaluateJavaScript(string, completionHandler: completionHandler)
         } else {
+            weak var weakSelf = self
             dispatch_async(dispatch_get_main_queue()) {
-                self._webView.evaluateJavaScript(string, completionHandler: completionHandler)
+                if let strongSelf = weakSelf {
+                    strongSelf.webView.evaluateJavaScript(string, completionHandler: completionHandler)
+                }
             }
         }
     }

import WebKit

public class XWalkChannel : NSObject, WKScriptMessageHandler {
    private let _name: String
    private weak var _webView: WKWebView!
    private var _thread: NSThread = NSThread.mainThread()
    private var _namespace: String = ""

    private var instances: [Int: AnyObject] = [:]
    public var mirror: XWalkReflection!
    private var userScript: WKUserScript?

    public var name: String { return _name }
    public weak var webView: WKWebView! { return _webView }
    public var thread: NSThread { return _thread }
    public var namespace: String { return _namespace }

    public init(webView: WKWebView, name: String? = nil) {
        struct seq{
            static var num: UInt32 = 0
        }

        _webView = webView
        _name = name ?? "\(++seq.num)"
        super.init()
        webView.configuration.userContentController.addScriptMessageHandler(self, name: "\(_name)")
    }

    public func bind(object: AnyObject, namespace: String, thread: NSThread? = nil) {
        _namespace = namespace
        _thread = thread ?? _webView.extensionThread
        if _thread is XWalkThread && !_thread.executing {
            _thread.start()
        }

        mirror = XWalkReflection(cls: object.dynamicType)
        var script = XWalkStubGenerator(reflection: mirror).generate(_name, namespace: namespace, object: object)
        let delegate = object as? XWalkDelegate
        script = delegate?.didGenerateStub?(script) ?? script

        userScript = _webView.injectScript(script)
        delegate?.didBindExtension?(self, instance: 0)
        instances[0] = object
    }

                let delegate = object as? XWalkDelegate
                if delegate?.setNativeProperty != nil {
                    let selector = Selector("setNativeProperty:value:")
                    Invocation.call(object, selector: selector, arguments: [prop, value], thread: thread)
                } else if mirror.hasProperty(prop) {
                    let selector = mirror.getSetter(prop)
                    if selector != Selector() {
                        Invocation.call(object, selector: selector, arguments: [value], thread: thread)
                    } else {
                        println("ERROR: Property '\(prop)' is readonly.")
                    }
