   */
   public var streamResponses = false
 
-  private var socket: Socket?
-  private var thread: Thread?
-
   public func run(at path: String) -> Completable {
     Completable.create { completable in
       self.queue.async {
-        self.stopLock.withWriteLock {
-          self.stopped = false
-
-          do {
-            try self.socket = Socket.create(
-              family: .unix,
-              type: .stream,
-              proto: .unix
-            )
-            try self.socket?.connect(to: path)
-            self.setUpThreadAndStartReading()
-          } catch {
-            self.streamSubject.onError(
-              Error(msg: "Could not get socket", cause: error)
-            )
-            completable(.error(
-              Error(msg: "Could not get socket at \(path)", cause: error)
-            ))
-          }
+        self.stopped = false
+
+        do {
+          try self.socket = Socket.create(
+            family: .unix,
+            type: .stream,
+            proto: .unix
+          )
+          try self.socket?.connect(to: path)
+          self.setUpThreadAndStartReading()
+        } catch {
+          self.streamSubject.onError(
+            Error(msg: "Could not get socket", cause: error)
+          )
+          completable(.error(
+            Error(msg: "Could not get socket at \(path)", cause: error)
+          ))
         }
 
         completable(.completed)

          ]
        )

        self.stopLock.withReadLock {
          if self.stopped {
            single(.error(Error(msg: "Connection stopped, " +
                                     "but trying to send a request with msg id \(msgid)")))
            return
          }

          guard let socket = self.socket else {
            single(.error(Error(msg: "Socket is invalid, " +
                                     "but trying to send a request with msg id \(msgid)")))
            return
          }

          if expectsReturnValue {
            self.singlesLock.withLock {
              self.singles[msgid] = single
            }
          }

          do {
            let writtenBytes = try socket.write(from: packed)
            if writtenBytes < packed.count {
              single(.error(Error(
                msg: "(Written) = \(writtenBytes) < \(packed.count) = " +
                     "(requested) for msg id: \(msgid)"
              )))

              return
            }
          } catch {
            self.streamSubject.onError(Error(
              msg: "Could not write to socket for msg id: \(msgid)", cause: error))

            single(.error(Error(
              msg: "Could not write to socket for msg id: \(msgid)", cause: error)))

            return
          }

          if !expectsReturnValue {
            single(.success(self.nilResponse(with: msgid)))
          }
        }
      }


  public func stop() -> Completable {
    Completable.create { completable in
      self.queue.async {
        self.streamSubject.onCompleted()
        self.cleanUpAndCloseSocket()

        completable(.completed)
      }
      return Disposables.create()
    }
