     self.transport = WebsocketTransport(url: aFayeURLString)
     self.transport!.delegate = self;
 
-    if(channel != nil){
-      self.queuedSubscriptions.addObject(channel!)
+    if let chan = channel {
+      self.queuedSubscriptions.addObject(chan)
     }
     self.connectionInitiated = false
   }
 
-  public convenience init(aFayeURLString:String, channel:String, channelBlock:ChannelSubscriptionBlock){
+  public convenience init(aFayeURLString:String, channel:String, channelBlock:ChannelSubscriptionBlock) {
     self.init(aFayeURLString: aFayeURLString, channel: channel)
     self.channelSubscriptionBlocks[channel] = channelBlock;
   }
 
-  public func connectToServer(){
-    if(self.connectionInitiated != true){
+  public func connectToServer() {
+    if self.connectionInitiated != true {
       self.transport?.openConnection()
       self.connectionInitiated = true;
     }
   }
 
-  public func disconnectFromServer(){
+  public func disconnectFromServer() {
     self.disconnect()
   }
 
-  public func sendMessage(messageDict: NSDictionary, channel:String){
+  public func sendMessage(messageDict: NSDictionary, channel:String) {
     self.publish(messageDict as! Dictionary, channel: channel)
   }
 
-  public func sendMessage(messageDict:[String:AnyObject], channel:String){
+  public func sendMessage(messageDict:[String:AnyObject], channel:String) {
     self.publish(messageDict, channel: channel)
   }
 
-  public func subscribeToChannel(channel:String){
-    if(self.isSubscribedToChannel(channel) || self.pendingSubscriptions.containsObject(channel) ){
+  public func subscribeToChannel(channel:String) {
+    if self.isSubscribedToChannel(channel) || self.pendingSubscriptions.containsObject(channel) {
       return
     }
 
-    if(self.fayeConnected == true){
+    if self.fayeConnected == true {
       self.subscribe(channel)
-    }else{
+    } else {
       self.queuedSubscriptions.addObject(channel)
     }
   }
 
-  public func subscribeToChannel(channel:String, block:ChannelSubscriptionBlock){
+  public func subscribeToChannel(channel:String, block:ChannelSubscriptionBlock) {
     self.subscribeToChannel(channel)
     self.channelSubscriptionBlocks[channel] = block;
   }
 
-  public func unsubscribeFromChannel(channel:String){
+  public func unsubscribeFromChannel(channel:String) {
     self.queuedSubscriptions.removeObject(channel)
     self.unsubscribe(channel)
     self.channelSubscriptionBlocks[channel] = nil;


// MARK: Private Bayuex Methods
private extension FayeClient {
  func parseFayeMessage(messageJSON:JSON){

    let messageDict = messageJSON[0]
    if let channel = messageDict["channel"].string {

      switch(channel)
      {
      case BayeuxChannel.HANDSHAKE_CHANNEL.description:
        self.fayeClientId = messageDict["clientId"].stringValue
        if(messageDict["successful"].int == 1){

          self.delegate?.connectedToServer(self)
          self.fayeConnected = true;
          self.connect()
          self.subscribeQueuedSubscriptions()

        }else{
          // OOPS
        }

      case BayeuxChannel.CONNECT_CHANNEL.description:
        if(messageDict["successful"].int == 1){
          self.fayeConnected = true;
          self.connect()
        }else{
          // OOPS
        }
      case BayeuxChannel.DISCONNECT_CHANNEL.description:
        if(messageDict["successful"].int == 1){
          self.fayeConnected = false;
          self.transport?.closeConnection()
          self.delegate?.disconnectedFromServer(self)
        }else{
          // OOPS
        }
      case BayeuxChannel.SUBSCRIBE_CHANNEL.description:
        let success = messageJSON[0]["successful"].int

        if( success == 1){
          if let subscription = messageJSON[0]["subscription"].string {
            self.pendingSubscriptions.removeObject(subscription)
            self.openSubscriptions.addObject(subscription)
            self.delegate?.didSubscribeToChannel(self, channel: subscription)
          }else{
            print("Missing subscription for Subscribe")
          }
        }else{
          // Subscribe Failed
          if let error = messageJSON[0]["error"].string{
            self.delegate?.subscriptionFailedWithError(self, error: error)
          }
        }
      case BayeuxChannel.UNSUBSCRIBE_CHANNEL.description:
        if let subscription = messageJSON[0]["subscription"].string {
          self.openSubscriptions.removeObject(subscription)
          self.delegate?.didUnsubscribeFromChannel(self, channel: subscription)
        }else{
          print("Missing subscription for Unsubscribe")
        }
      default:
        if(self.isSubscribedToChannel(channel)){
          if(messageJSON[0]["data"] != JSON.null){
            // Call channel subscription block if there is one
            let data: AnyObject = messageJSON[0]["data"].object
            if let channelBlock = self.channelSubscriptionBlocks[channel] {
              channelBlock(data as! NSDictionary)
            }else{
              self.delegate?.messageReceived(self, messageDict: data as! NSDictionary, channel: channel)
            }

          }else{
            print("For some reason data is nil, maybe double posting?!")
          }

        }else{
          print("weird channel")
        }
      }

    }else{
      print("Missing channel")
    }
  }

  // "clientId": "Un1q31d3nt1f13r",
  // "subscription": "/foo/**"
  // }
  func unsubscribe(channel:String) {
    if let clientId = self.fayeClientId {
      let dict:[String:AnyObject] = ["channel": BayeuxChannel.UNSUBSCRIBE_CHANNEL.rawValue, "clientId": clientId, "subscription": channel]
      if let string = JSON(dict).rawString() {
        self.transport?.writeString(string)
      }
