         if inputBytes != nil {
             free(inputBytes)
         }
-        pthread_mutex_init(&mutex, nil)
+        pthread_mutex_init(mutex, nil)
+        mutex.deallocate()
     }
     @inline(__always) fileprivate func lock(){
-        pthread_mutex_lock(&mutex)
+        pthread_mutex_lock(mutex)
     }
     @inline(__always) fileprivate func unlock(){
-        pthread_mutex_unlock(&mutex)
+        pthread_mutex_unlock(mutex)
     }
 
     fileprivate var dirty : Bool {

    }

    init(request: URLRequest, subProtocols : [String] = [], stub : Bool = false){
        pthread_mutex_init(&mutex, nil)
        self.id = manager.nextId()
        self.request = request
        self.subProtocols = subProtocols

/// WebSocket objects are bidirectional network streams that communicate over HTTP. RFC 6455.
private class InnerWebSocket: Hashable {
    var id : Int
    var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
    let request : URLRequest!
    let subProtocols : [String]!
    var frames : [Frame] = []
