         return (event["id"], event["event"], event["data"])
     }
 
+    private func parseKeyValuePair(line: String) -> (NSString?, NSString?) {
+        var key: NSString?, value: NSString?
+        let scanner = NSScanner(string: line)
+        scanner.scanUpToString(":", intoString: &key)
+        scanner.scanString(":", intoString: nil)
+
+        for newline in validNewlineCharacters {
+            if scanner.scanUpToString(newline, intoString: &value) {
+                break
+            }
+        }
+
+        return (key, value)
+    }
+
     private func parseRetryTime(eventString: String) -> Int? {
         var reconnectTime: Int?
         let separators = NSCharacterSet(charactersInString: ":")

            // Search for next occurrence of delimiter
            searchRange.location = foundRange.location + foundRange.length
            searchRange.length = receivedDataBuffer.length - searchRange.location
            foundRange = receivedDataBuffer.rangeOfData(delimiter, options: NSDataSearchOptions(), range: searchRange)
        }

        // Remove the found events from the buffer
        self.receivedDataBuffer.replaceBytesInRange(NSRange(location: 0, length: searchRange.location), withBytes: nil, length: 0)

        return events
    }

    private func parseEventStream(events: [String]) {

//MARK: Helpers

    private func extractEventsFromBuffer() -> [String] {
        var events = [String]()

        // Find first occurrence of delimiter
		var searchRange =  NSRange(location: 0, length: receivedDataBuffer.length)
        while let foundRange = searchForEventInRange(searchRange) {
            // Append event
            if foundRange.location > searchRange.location {
                let dataChunk = receivedDataBuffer.subdataWithRange(
