                                            configuration.port,
                                            &readStream,
                                            &writeStream)
-        
-        input = readStream?.takeRetainedValue()
-        output = writeStream?.takeRetainedValue()
-        streamQueue.async { [weak self] in
-            
-            self?.configureAndOpen(stream: self?.input)
-            self?.configureAndOpen(stream: self?.output)
-            RunLoop.current.run()
-        }
-        streamQueue.async { [weak self] in
-            self?.startTimeoutTimer()
-        }
-    }
-    
-    private func configureAndOpen(stream: Stream?) {
-        
-        stream?.delegate = streamsDelegate
-        stream?.schedule(in: RunLoop.current, forMode: .defaultRunLoopMode)
-        stream?.open()
-    }
-    
+        guard let inputStream: InputStream = readStream?.takeRetainedValue(),
+            let outputStream: OutputStream = writeStream?.takeRetainedValue() else {
+            state = .error(.unknown)
+            return
+        }
+        pthread_rwlock_wrlock(&streamLock)
+        input = inputStream
+        output = outputStream
+        inputStream.delegate = self.streamsDelegate
+        outputStream.delegate = self.streamsDelegate
+        CFReadStreamSetDispatchQueue(input, streamQueue)
+        CFWriteStreamSetDispatchQueue(output, streamQueue)
+        outputStream.open()
+        outputStream.open()
+        pthread_rwlock_wrlock(&streamLock)
+    }
+
     // MARK: - Close -
     open func close() {
         guard state != .closed else { return }

        self.configuration = configuration
        self.completionQueue = completionQueue
        self.streamsDelegate = OBDStreamDelegate()
        self.streamsDelegate.onStreamEvent = { [weak self] (stream, event) in
            self?.handleEvent(code: event, inStream: stream)
        }

    
    private func finishTransmission(result: OBDResult<String>) {
        
        invalidateRequestTimeoutTimer()
        let completion = requestCompletion
        requestCompletion = nil
        requestResponse = ""
        completionQueue.async {
            completion?(result)
        }
