     private var errorBeforeSetErrorCallBack: NSError?
     internal let receivedDataBuffer: NSMutableData
 	private let uniqueIdentifier: String
+    private let validNewlineCharacters = ["\r\n", "\n", "\r"]
 
     var event = Dictionary<String, String>()
 

//MARK: Helpers

    private func extractEventsFromBuffer() -> [String] {
        let delimiter = "\n\n".dataUsingEncoding(NSUTF8StringEncoding)!
        var events = [String]()

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


        for line in eventString.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet()) as [String] {
            autoreleasepool {
                let (key, value) = self.parseKeyValuePair(line)

                if key != nil && value != nil {
                    if event[key as! String] != nil {
