 import Foundation
 import WebRTC
 
-private let peerChannelSignalingStateTable: PairTable<PeerChannelSignalingState, RTCSignalingState> =
-    PairTable(name: "PeerChannelSignalingState",
-              pairs: [(.stable, .stable),
-                      (.haveLocalOffer, .haveLocalOffer),
-                      (.haveLocalPrAnswer, .haveLocalPrAnswer),
-                      (.haveRemoteOffer, .haveRemoteOffer),
-                      (.haveRemotePrAnswer, .haveRemotePrAnswer),
-                      (.closed, .closed)])
-
-private let iceConnectionStateTable: PairTable<ICEConnectionState, RTCIceConnectionState> =
-    PairTable(name: "ICEConnectionState",
-              pairs: [(.new, .new),
-                      (.checking, .checking),
-                      (.connected, .connected),
-                      (.completed, .completed),
-                      (.failed, .failed),
-                      (.disconnected, .disconnected),
-                      (.closed, .closed),
-                      (.count, .count)])
-
-private let iceGatheringStateTable: PairTable<ICEGatheringState, RTCIceGatheringState> =
-    PairTable(name: "ICEGatheringState",
-              pairs: [(.new, .new),
-                      (.gathering, .gathering),
-                      (.complete, .complete)])
-
-enum PeerChannelSignalingState {
-    
-    case stable
-    case haveLocalOffer
-    case haveLocalPrAnswer
-    case haveRemoteOffer
-    case haveRemotePrAnswer
-    case closed
-    
-    init(nativeValue: RTCSignalingState) {
-        self = peerChannelSignalingStateTable.left(other: nativeValue)!
-    }
-    
-}
-
-enum ICEConnectionState {
-    
-    case new
-    case checking
-    case connected
-    case completed
-    case failed
-    case disconnected
-    case closed
-    case count
-    
-    init(nativeValue: RTCIceConnectionState) {
-        self = iceConnectionStateTable.left(other: nativeValue)!
-    }
-    
-}
-
-enum ICEGatheringState {
-    
-    case new
-    case gathering
-    case complete
-    
-    init(nativeValue: RTCIceGatheringState) {
-        self = iceGatheringStateTable.left(other: nativeValue)!
-    }
-    
-}
-
 class PeerChannelInternalState {
     
-    var signalingState: PeerChannelSignalingState {
+    var signalingState: RTCSignalingState {
         didSet { validate() }
     }
     
-    var iceConnectionState: ICEConnectionState {
+    var iceConnectionState: RTCIceConnectionState {
         didSet { validate() }
     }
     
-    var iceGatheringState: ICEGatheringState {
+    var iceGatheringState: RTCIceGatheringState {
         didSet { validate() }
     }
     

    
    func peerConnection(_ nativePeerConnection: RTCPeerConnection,
                        didChange newState: RTCIceConnectionState) {
        let newState = ICEConnectionState(nativeValue: newState)
        Logger.debug(type: .peerChannel,
                     message: "changed ICE connection state to \(newState)")
        internalState.iceConnectionState = newState

    
    func peerConnection(_ nativePeerConnection: RTCPeerConnection,
                        didChange stateChanged: RTCSignalingState) {
        Logger.debug(type: .peerChannel,
                     message: "changed signaling state to \(stateChanged)")
        internalState.signalingState = stateChanged
    }
    
    func peerConnection(_ nativePeerConnection: RTCPeerConnection,
