                 let delegate = object as? XWalkDelegate
                 if delegate?.setNativeProperty != nil {
                     let selector = Selector("setNativeProperty:value:")
-                    Invocation.call(object, selector: selector, arguments: [prop, value], thread: _thread)
+                    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)
+                        Invocation.call(object, selector: selector, arguments: [value], thread: thread)
                     } else {
                         println("ERROR: Property '\(prop)' is readonly.")
                     }

            (object as? XWalkDelegate)?.didUnbindExtension?()
        } else if body["destroy"] != nil {
            // Destroy extension
            if _webView.URL != nil {
                evaluateJavaScript("delete \(_namespace);", completionHandler:nil)
            }
            _webView.configuration.userContentController.removeScriptMessageHandlerForName("\(_name)")
            if userScript != nil {
                _webView.configuration.userContentController.removeUserScript(userScript!)
            }
            for (_, object) in instances {
                (object as? XWalkDelegate)?.didUnbindExtension?()

    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)
        } else {
            weak var weakSelf = self
            dispatch_async(dispatch_get_main_queue()) {
                if let strongSelf = weakSelf {
                    strongSelf.webView.evaluateJavaScript(string, completionHandler: completionHandler)
                }
            }
        }
    }
