Merge branch 'pr/334'
diff --git a/CoreFoundation/Base.subproj/CFInternal.h b/CoreFoundation/Base.subproj/CFInternal.h
index 6c0b271..fa2d552 100644
--- a/CoreFoundation/Base.subproj/CFInternal.h
+++ b/CoreFoundation/Base.subproj/CFInternal.h
@@ -805,7 +805,12 @@
 #define pthread_setname_np _NS_pthread_setname_np
 #endif
 
-#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+#if DEPLOYMENT_TARGET_LINUX
+CF_EXPORT Boolean _CFIsMainThread(void);
+#define pthread_main_np _CFIsMainThread
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
 // replacement for DISPATCH_QUEUE_OVERCOMMIT until we get a bug fix in dispatch on Windows
 // <rdar://problem/7923891> dispatch on Windows: Need queue_private.h
 #define DISPATCH_QUEUE_OVERCOMMIT 2
diff --git a/CoreFoundation/Base.subproj/CFPlatform.c b/CoreFoundation/Base.subproj/CFPlatform.c
index eefc1c9..9311c17 100644
--- a/CoreFoundation/Base.subproj/CFPlatform.c
+++ b/CoreFoundation/Base.subproj/CFPlatform.c
@@ -157,6 +157,11 @@
 
 #if DEPLOYMENT_TARGET_LINUX
 #include <unistd.h>
+#include <syscall.h>
+
+Boolean _CFIsMainThread(void) {
+    return syscall(SYS_gettid) == getpid();
+}
 
 const char *_CFProcessPath(void) {
     if (__CFProcessPath) return __CFProcessPath;
diff --git a/CoreFoundation/RunLoop.subproj/CFRunLoop.c b/CoreFoundation/RunLoop.subproj/CFRunLoop.c
index 12f7ea8..ec4550e 100644
--- a/CoreFoundation/RunLoop.subproj/CFRunLoop.c
+++ b/CoreFoundation/RunLoop.subproj/CFRunLoop.c
@@ -78,8 +78,8 @@
 #include <sys/eventfd.h>
 #include <sys/timerfd.h>
 
-#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_np
-#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_np()
+#define _dispatch_get_main_queue_port_4CF dispatch_get_main_queue_eventfd_4CF
+#define _dispatch_main_queue_callback_4CF(x) dispatch_main_queue_drain_4CF()
 #endif
 
 #if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_IPHONESIMULATOR || DEPLOYMENT_TARGET_LINUX
diff --git a/Foundation.xcodeproj/project.pbxproj b/Foundation.xcodeproj/project.pbxproj
index 947782d..0fcd123 100755
--- a/Foundation.xcodeproj/project.pbxproj
+++ b/Foundation.xcodeproj/project.pbxproj
@@ -340,6 +340,7 @@
 		EADE0BCB1BD15E0000C49C64 /* NSXMLNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B8D1BD15DFF00C49C64 /* NSXMLNode.swift */; };
 		EADE0BCC1BD15E0000C49C64 /* NSXMLNodeOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B8E1BD15DFF00C49C64 /* NSXMLNodeOptions.swift */; };
 		EADE0BCD1BD15E0000C49C64 /* NSXMLParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B8F1BD15DFF00C49C64 /* NSXMLParser.swift */; };
+		F9E0BB371CA70B8000F7FF3C /* TestNSURLCredential.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9E0BB361CA70B8000F7FF3C /* TestNSURLCredential.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -738,6 +739,7 @@
 		EADE0B8D1BD15DFF00C49C64 /* NSXMLNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSXMLNode.swift; sourceTree = "<group>"; };
 		EADE0B8E1BD15DFF00C49C64 /* NSXMLNodeOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSXMLNodeOptions.swift; sourceTree = "<group>"; };
 		EADE0B8F1BD15DFF00C49C64 /* NSXMLParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSXMLParser.swift; sourceTree = "<group>"; };
+		F9E0BB361CA70B8000F7FF3C /* TestNSURLCredential.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSURLCredential.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1203,6 +1205,7 @@
 				61D6C9EE1C1DFE9500DEF583 /* TestNSTimer.swift */,
 				84BA558D1C16F90900F48C54 /* TestNSTimeZone.swift */,
 				EA66F6431BF1619600136161 /* TestNSURL.swift */,
+				F9E0BB361CA70B8000F7FF3C /* TestNSURLCredential.swift */,
 				83712C8D1C1684900049AD49 /* TestNSURLRequest.swift */,
 				7A7D6FBA1C16439400957E2E /* TestNSURLResponse.swift */,
 				555683BC1C1250E70041D4C6 /* TestNSUserDefaults.swift */,
@@ -1979,6 +1982,7 @@
 				5B13B32F1C582D4C00651CE2 /* TestNSGeometry.swift in Sources */,
 				5B13B3351C582D4C00651CE2 /* TestNSKeyedUnarchiver.swift in Sources */,
 				5B13B33D1C582D4C00651CE2 /* TestNSPipe.swift in Sources */,
+				F9E0BB371CA70B8000F7FF3C /* TestNSURLCredential.swift in Sources */,
 				5B13B3341C582D4C00651CE2 /* TestNSKeyedArchiver.swift in Sources */,
 				5B13B3441C582D4C00651CE2 /* TestNSSet.swift in Sources */,
 				5B13B3321C582D4C00651CE2 /* TestNSIndexSet.swift in Sources */,
diff --git a/Foundation/FoundationErrors.swift b/Foundation/FoundationErrors.swift
index 7b0c8f8..dad009d 100644
--- a/Foundation/FoundationErrors.swift
+++ b/Foundation/FoundationErrors.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSAffineTransform.swift b/Foundation/NSAffineTransform.swift
index 201472e..38ffb82 100644
--- a/Foundation/NSAffineTransform.swift
+++ b/Foundation/NSAffineTransform.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSArray.swift b/Foundation/NSArray.swift
index d85e73d..ef9f5c1 100644
--- a/Foundation/NSArray.swift
+++ b/Foundation/NSArray.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSAttributedString.swift b/Foundation/NSAttributedString.swift
index ad171d9..49cca6c 100644
--- a/Foundation/NSAttributedString.swift
+++ b/Foundation/NSAttributedString.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSBundle.swift b/Foundation/NSBundle.swift
index 6293040..f834568 100644
--- a/Foundation/NSBundle.swift
+++ b/Foundation/NSBundle.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSByteCountFormatter.swift b/Foundation/NSByteCountFormatter.swift
index 98fed1f..53a4bdc 100644
--- a/Foundation/NSByteCountFormatter.swift
+++ b/Foundation/NSByteCountFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCFArray.swift b/Foundation/NSCFArray.swift
index f3e09fe..e3e8d97 100644
--- a/Foundation/NSCFArray.swift
+++ b/Foundation/NSCFArray.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCFDictionary.swift b/Foundation/NSCFDictionary.swift
index d68a73b..5d69d31 100644
--- a/Foundation/NSCFDictionary.swift
+++ b/Foundation/NSCFDictionary.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCFSet.swift b/Foundation/NSCFSet.swift
index 85d7791..ccd6403 100644
--- a/Foundation/NSCFSet.swift
+++ b/Foundation/NSCFSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCFString.swift b/Foundation/NSCFString.swift
index 4fb5640..634093b 100644
--- a/Foundation/NSCFString.swift
+++ b/Foundation/NSCFString.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -44,11 +44,11 @@
         return CFStringGetLength(unsafeBitCast(self, to: CFString.self))
     }
     
-    override func characterAtIndex(_ index: Int) -> unichar {
+    override func character(at index: Int) -> unichar {
         return CFStringGetCharacterAtIndex(unsafeBitCast(self, to: CFString.self), index)
     }
     
-    override func replaceCharactersInRange(_ range: NSRange, withString aString: String) {
+    override func replaceCharacters(in range: NSRange, with aString: String) {
         CFStringReplace(unsafeBitCast(self, to: CFMutableString.self), CFRangeMake(range.location, range.length), aString._cfObject)
     }
     
@@ -100,11 +100,11 @@
         return Int(_length)
     }
     
-    override func characterAtIndex(_ index: Int) -> unichar {
+    override func character(at index: Int) -> unichar {
         return unichar(_ptr[index])
     }
     
-    override func replaceCharactersInRange(_ range: NSRange, withString aString: String) {
+    override func replaceCharacters(in range: NSRange, with aString: String) {
         fatalError()
     }
     
@@ -118,7 +118,7 @@
 }
 
 internal func _CFSwiftStringGetCharacterAtIndex(_ str: AnyObject, index: CFIndex) -> UniChar {
-    return (str as! NSString).characterAtIndex(index)
+    return (str as! NSString).character(at: index)
 }
 
 internal func _CFSwiftStringGetCharacters(_ str: AnyObject, range: CFRange, buffer: UnsafeMutablePointer<UniChar>) {
@@ -133,7 +133,8 @@
         let start = encodingView.startIndex
         if let buffer = buffer {
             for idx in 0..<range.length {
-                let character = encodingView[start.advanced(by: idx + range.location)]
+                let characterIndex = encodingView.index(start, offsetBy: idx + range.location)
+                let character = encodingView[characterIndex]
                 buffer.advanced(by: idx).initialize(with: character)
             }
         }
@@ -164,7 +165,7 @@
 }
 
 internal func _CFSwiftStringCreateWithSubstring(_ str: AnyObject, range: CFRange) -> Unmanaged<AnyObject> {
-    return Unmanaged<AnyObject>.passRetained((str as! NSString).substringWithRange(NSMakeRange(range.location, range.length))._nsObject)
+    return Unmanaged<AnyObject>.passRetained((str as! NSString).substring(with: NSMakeRange(range.location, range.length))._nsObject)
 }
 
 
@@ -193,15 +194,15 @@
 }
 
 internal func _CFSwiftStringInsert(_ str: AnyObject, index: CFIndex, inserted: AnyObject) {
-    (str as! NSMutableString).insertString((inserted as! NSString)._swiftObject, atIndex: index)
+    (str as! NSMutableString).insert((inserted as! NSString)._swiftObject, at: index)
 }
 
 internal func _CFSwiftStringDelete(_ str: AnyObject, range: CFRange) {
-    (str as! NSMutableString).deleteCharactersInRange(NSMakeRange(range.location, range.length))
+    (str as! NSMutableString).deleteCharacters(in: NSMakeRange(range.location, range.length))
 }
 
 internal func _CFSwiftStringReplace(_ str: AnyObject, range: CFRange, replacement: AnyObject) {
-    (str as! NSMutableString).replaceCharactersInRange(NSMakeRange(range.location, range.length), withString: (replacement as! NSString)._swiftObject)
+    (str as! NSMutableString).replaceCharacters(in: NSMakeRange(range.location, range.length), with: (replacement as! NSString)._swiftObject)
 }
 
 internal func _CFSwiftStringReplaceAll(_ str: AnyObject, replacement: AnyObject) {
@@ -209,7 +210,7 @@
 }
 
 internal func _CFSwiftStringAppend(_ str: AnyObject, appended: AnyObject) {
-    (str as! NSMutableString).appendString((appended as! NSString)._swiftObject)
+    (str as! NSMutableString).append((appended as! NSString)._swiftObject)
 }
 
 internal func _CFSwiftStringAppendCharacters(_ str: AnyObject, chars: UnsafePointer<UniChar>, length: CFIndex) {
diff --git a/Foundation/NSCache.swift b/Foundation/NSCache.swift
index c5244e4..9588fbb 100644
--- a/Foundation/NSCache.swift
+++ b/Foundation/NSCache.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCalendar.swift b/Foundation/NSCalendar.swift
index ea01bbc..3ef5cd5 100644
--- a/Foundation/NSCalendar.swift
+++ b/Foundation/NSCalendar.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -52,23 +52,23 @@
     public let rawValue : UInt
     public init(rawValue: UInt) { self.rawValue = rawValue }
     
-    public static let Era = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitEra))
-    public static let Year = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitYear))
-    public static let Month = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitMonth))
-    public static let Day = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitDay))
-    public static let Hour = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitHour))
-    public static let Minute = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitMinute))
-    public static let Second = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitSecond))
-    public static let Weekday = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekday))
-    public static let WeekdayOrdinal = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekdayOrdinal))
-    public static let Quarter = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitQuarter))
-    public static let WeekOfMonth = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekOfMonth))
-    public static let WeekOfYear = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekOfYear))
-    public static let YearForWeekOfYear = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitYearForWeekOfYear))
+    public static let era = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitEra))
+    public static let year = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitYear))
+    public static let month = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitMonth))
+    public static let day = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitDay))
+    public static let hour = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitHour))
+    public static let minute = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitMinute))
+    public static let second = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitSecond))
+    public static let weekday = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekday))
+    public static let weekdayOrdinal = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekdayOrdinal))
+    public static let quarter = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitQuarter))
+    public static let weekOfMonth = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekOfMonth))
+    public static let weekOfYear = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitWeekOfYear))
+    public static let yearForWeekOfYear = NSCalendarUnit(rawValue: UInt(kCFCalendarUnitYearForWeekOfYear))
 
-    public static let Nanosecond = NSCalendarUnit(rawValue: UInt(1 << 15))
-    public static let Calendar = NSCalendarUnit(rawValue: UInt(1 << 20))
-    public static let TimeZone = NSCalendarUnit(rawValue: UInt(1 << 21))
+    public static let nanosecond = NSCalendarUnit(rawValue: UInt(1 << 15))
+    public static let calendar = NSCalendarUnit(rawValue: UInt(1 << 20))
+    public static let timeZone = NSCalendarUnit(rawValue: UInt(1 << 21))
     
     internal var _cfValue: CFCalendarUnit {
 #if os(OSX) || os(iOS)
@@ -83,14 +83,14 @@
     public let rawValue : UInt
     public init(rawValue: UInt) { self.rawValue = rawValue }
     
-    public static let WrapComponents = NSCalendarOptions(rawValue: 1 << 0)
-    public static let MatchStrictly = NSCalendarOptions(rawValue: 1 << 1)
-    public static let SearchBackwards = NSCalendarOptions(rawValue: 1 << 2)
-    public static let MatchPreviousTimePreservingSmallerUnits = NSCalendarOptions(rawValue: 1 << 8)
-    public static let MatchNextTimePreservingSmallerUnits = NSCalendarOptions(rawValue: 1 << 9)
-    public static let MatchNextTime = NSCalendarOptions(rawValue: 1 << 10)
-    public static let MatchFirst = NSCalendarOptions(rawValue: 1 << 12)
-    public static let MatchLast = NSCalendarOptions(rawValue: 1 << 13)
+    public static let wrapComponents = NSCalendarOptions(rawValue: 1 << 0)
+    public static let matchStrictly = NSCalendarOptions(rawValue: 1 << 1)
+    public static let searchBackwards = NSCalendarOptions(rawValue: 1 << 2)
+    public static let matchPreviousTimePreservingSmallerUnits = NSCalendarOptions(rawValue: 1 << 8)
+    public static let matchNextTimePreservingSmallerUnits = NSCalendarOptions(rawValue: 1 << 9)
+    public static let matchNextTime = NSCalendarOptions(rawValue: 1 << 10)
+    public static let matchFirst = NSCalendarOptions(rawValue: 1 << 12)
+    public static let matchLast = NSCalendarOptions(rawValue: 1 << 13)
 }
 
 public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
@@ -347,7 +347,7 @@
     
     // Calendrical calculations
     
-    public func minimumRangeOfUnit(_ unit: NSCalendarUnit) -> NSRange {
+    public func minimumRange(of unit: NSCalendarUnit) -> NSRange {
         let r = CFCalendarGetMinimumRangeOfUnit(self._cfObject, unit._cfValue)
         if (r.location == kCFNotFound) {
             return NSMakeRange(NSNotFound, NSNotFound)
@@ -355,7 +355,7 @@
         return NSMakeRange(r.location, r.length)
     }
     
-    public func maximumRangeOfUnit(_ unit: NSCalendarUnit) -> NSRange {
+    public func maximumRange(of unit: NSCalendarUnit) -> NSRange {
         let r = CFCalendarGetMaximumRangeOfUnit(_cfObject, unit._cfValue)
         if r.location == kCFNotFound {
             return NSMakeRange(NSNotFound, NSNotFound)
@@ -363,7 +363,7 @@
         return NSMakeRange(r.location, r.length)
     }
     
-    public func rangeOfUnit(_ smaller: NSCalendarUnit, inUnit larger: NSCalendarUnit, forDate date: NSDate) -> NSRange {
+    public func range(of smaller: NSCalendarUnit, in larger: NSCalendarUnit, for date: NSDate) -> NSRange {
         let r = CFCalendarGetRangeOfUnit(_cfObject, smaller._cfValue, larger._cfValue, date.timeIntervalSinceReferenceDate)
         if r.location == kCFNotFound {
             return NSMakeRange(NSNotFound, NSNotFound)
@@ -371,7 +371,7 @@
         return NSMakeRange(r.location, r.length)
     }
     
-    public func ordinalityOfUnit(_ smaller: NSCalendarUnit, inUnit larger: NSCalendarUnit, forDate date: NSDate) -> Int {
+    public func ordinality(of smaller: NSCalendarUnit, in larger: NSCalendarUnit, for date: NSDate) -> Int {
         return Int(CFCalendarGetOrdinalityOfUnit(_cfObject, smaller._cfValue, larger._cfValue, date.timeIntervalSinceReferenceDate))
     }
     
@@ -381,7 +381,7 @@
     /// which is not implementable on Linux due to the lack of being able to properly implement AutoreleasingUnsafeMutablePointer.
     /// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
     /// - Note: Since this API is under consideration it may be either removed or revised in the near future
-    public func rangeOfUnit(_ unit: NSCalendarUnit, forDate date: NSDate) -> NSDateInterval? {
+    public func range(of unit: NSCalendarUnit, forDate date: NSDate) -> NSDateInterval? {
         var start: CFAbsoluteTime = 0.0
         var ti: CFTimeInterval = 0.0
         let res: Bool = withUnsafeMutablePointers(&start, &ti) { startp, tip in
@@ -427,7 +427,7 @@
         return (vector, compDesc)
     }
     
-    public func dateFromComponents(_ comps: NSDateComponents) -> NSDate? {
+    public func date(from comps: NSDateComponents) -> NSDate? {
         var (vector, compDesc) = _convert(comps)
         
         self.timeZone = comps.timeZone ?? timeZone
@@ -454,21 +454,21 @@
     
     private func _setup(_ unitFlags: NSCalendarUnit) -> [Int8] {
         var compDesc = [Int8]()
-        _setup(unitFlags, field: .Era, type: "G", compDesc: &compDesc)
-        _setup(unitFlags, field: .Year, type: "y", compDesc: &compDesc)
-        _setup(unitFlags, field: .Quarter, type: "Q", compDesc: &compDesc)
-        _setup(unitFlags, field: .Month, type: "M", compDesc: &compDesc)
-        _setup(unitFlags, field: .Month, type: "l", compDesc: &compDesc)
-        _setup(unitFlags, field: .Day, type: "d", compDesc: &compDesc)
-        _setup(unitFlags, field: .WeekOfYear, type: "w", compDesc: &compDesc)
-        _setup(unitFlags, field: .WeekOfMonth, type: "W", compDesc: &compDesc)
-        _setup(unitFlags, field: .YearForWeekOfYear, type: "Y", compDesc: &compDesc)
-        _setup(unitFlags, field: .Weekday, type: "E", compDesc: &compDesc)
-        _setup(unitFlags, field: .WeekdayOrdinal, type: "F", compDesc: &compDesc)
-        _setup(unitFlags, field: .Hour, type: "H", compDesc: &compDesc)
-        _setup(unitFlags, field: .Minute, type: "m", compDesc: &compDesc)
-        _setup(unitFlags, field: .Second, type: "s", compDesc: &compDesc)
-        _setup(unitFlags, field: .Nanosecond, type: "#", compDesc: &compDesc)
+        _setup(unitFlags, field: .era, type: "G", compDesc: &compDesc)
+        _setup(unitFlags, field: .year, type: "y", compDesc: &compDesc)
+        _setup(unitFlags, field: .quarter, type: "Q", compDesc: &compDesc)
+        _setup(unitFlags, field: .month, type: "M", compDesc: &compDesc)
+        _setup(unitFlags, field: .month, type: "l", compDesc: &compDesc)
+        _setup(unitFlags, field: .day, type: "d", compDesc: &compDesc)
+        _setup(unitFlags, field: .weekOfYear, type: "w", compDesc: &compDesc)
+        _setup(unitFlags, field: .weekOfMonth, type: "W", compDesc: &compDesc)
+        _setup(unitFlags, field: .yearForWeekOfYear, type: "Y", compDesc: &compDesc)
+        _setup(unitFlags, field: .weekday, type: "E", compDesc: &compDesc)
+        _setup(unitFlags, field: .weekdayOrdinal, type: "F", compDesc: &compDesc)
+        _setup(unitFlags, field: .hour, type: "H", compDesc: &compDesc)
+        _setup(unitFlags, field: .minute, type: "m", compDesc: &compDesc)
+        _setup(unitFlags, field: .second, type: "s", compDesc: &compDesc)
+        _setup(unitFlags, field: .nanosecond, type: "#", compDesc: &compDesc)
         compDesc.append(0)
         return compDesc
     }
@@ -483,26 +483,26 @@
     private func _components(_ unitFlags: NSCalendarUnit, vector: [Int32]) -> NSDateComponents {
         var compIdx = 0
         let comps = NSDateComponents()
-        _setComp(unitFlags, field: .Era, vector: vector, compIndex: &compIdx) { comps.era = Int($0) }
-        _setComp(unitFlags, field: .Year, vector: vector, compIndex: &compIdx) { comps.year = Int($0) }
-        _setComp(unitFlags, field: .Quarter, vector: vector, compIndex: &compIdx) { comps.quarter = Int($0) }
-        _setComp(unitFlags, field: .Month, vector: vector, compIndex: &compIdx) { comps.month = Int($0) }
-        _setComp(unitFlags, field: .Month, vector: vector, compIndex: &compIdx) { comps.leapMonth = $0 != 0 }
-        _setComp(unitFlags, field: .Day, vector: vector, compIndex: &compIdx) { comps.day = Int($0) }
-        _setComp(unitFlags, field: .WeekOfYear, vector: vector, compIndex: &compIdx) { comps.weekOfYear = Int($0) }
-        _setComp(unitFlags, field: .WeekOfMonth, vector: vector, compIndex: &compIdx) { comps.weekOfMonth = Int($0) }
-        _setComp(unitFlags, field: .YearForWeekOfYear, vector: vector, compIndex: &compIdx) { comps.yearForWeekOfYear = Int($0) }
-        _setComp(unitFlags, field: .Weekday, vector: vector, compIndex: &compIdx) { comps.weekday = Int($0) }
-        _setComp(unitFlags, field: .WeekdayOrdinal, vector: vector, compIndex: &compIdx) { comps.weekdayOrdinal = Int($0) }
-        _setComp(unitFlags, field: .Hour, vector: vector, compIndex: &compIdx) { comps.hour = Int($0) }
-        _setComp(unitFlags, field: .Minute, vector: vector, compIndex: &compIdx) { comps.minute = Int($0) }
-        _setComp(unitFlags, field: .Second, vector: vector, compIndex: &compIdx) { comps.second = Int($0) }
-        _setComp(unitFlags, field: .Nanosecond, vector: vector, compIndex: &compIdx) { comps.nanosecond = Int($0) }
+        _setComp(unitFlags, field: .era, vector: vector, compIndex: &compIdx) { comps.era = Int($0) }
+        _setComp(unitFlags, field: .year, vector: vector, compIndex: &compIdx) { comps.year = Int($0) }
+        _setComp(unitFlags, field: .quarter, vector: vector, compIndex: &compIdx) { comps.quarter = Int($0) }
+        _setComp(unitFlags, field: .month, vector: vector, compIndex: &compIdx) { comps.month = Int($0) }
+        _setComp(unitFlags, field: .month, vector: vector, compIndex: &compIdx) { comps.leapMonth = $0 != 0 }
+        _setComp(unitFlags, field: .day, vector: vector, compIndex: &compIdx) { comps.day = Int($0) }
+        _setComp(unitFlags, field: .weekOfYear, vector: vector, compIndex: &compIdx) { comps.weekOfYear = Int($0) }
+        _setComp(unitFlags, field: .weekOfMonth, vector: vector, compIndex: &compIdx) { comps.weekOfMonth = Int($0) }
+        _setComp(unitFlags, field: .yearForWeekOfYear, vector: vector, compIndex: &compIdx) { comps.yearForWeekOfYear = Int($0) }
+        _setComp(unitFlags, field: .weekday, vector: vector, compIndex: &compIdx) { comps.weekday = Int($0) }
+        _setComp(unitFlags, field: .weekdayOrdinal, vector: vector, compIndex: &compIdx) { comps.weekdayOrdinal = Int($0) }
+        _setComp(unitFlags, field: .hour, vector: vector, compIndex: &compIdx) { comps.hour = Int($0) }
+        _setComp(unitFlags, field: .minute, vector: vector, compIndex: &compIdx) { comps.minute = Int($0) }
+        _setComp(unitFlags, field: .second, vector: vector, compIndex: &compIdx) { comps.second = Int($0) }
+        _setComp(unitFlags, field: .nanosecond, vector: vector, compIndex: &compIdx) { comps.nanosecond = Int($0) }
         
-        if unitFlags.contains(.Calendar) {
+        if unitFlags.contains(.calendar) {
             comps.calendar = self
         }
-        if unitFlags.contains(.TimeZone) {
+        if unitFlags.contains(.timeZone) {
             comps.timeZone = timeZone
         }
         return comps
@@ -510,7 +510,7 @@
     
     /// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
     /// The Darwin version is not nullable but this one is since the conversion from the date and unit flags can potentially return nil
-    public func components(_ unitFlags: NSCalendarUnit, fromDate date: NSDate) -> NSDateComponents? {
+    public func components(_ unitFlags: NSCalendarUnit, from date: NSDate) -> NSDateComponents? {
         let compDesc = _setup(unitFlags)
         
         // _CFCalendarDecomposeAbsoluteTimeV requires a bit of a funky vector layout; which does not express well in swift; this is the closest I can come up with to the required format
@@ -533,7 +533,7 @@
         return nil
     }
     
-    public func dateByAddingComponents(_ comps: NSDateComponents, toDate date: NSDate, options opts: NSCalendarOptions) -> NSDate? {
+    public func date(byAdding comps: NSDateComponents, to date: NSDate, options opts: NSCalendarOptions = []) -> NSDate? {
         var (vector, compDesc) = _convert(comps)
         var at: CFAbsoluteTime = 0.0
         
@@ -550,7 +550,7 @@
         return nil
     }
     
-    public func components(_ unitFlags: NSCalendarUnit, fromDate startingDate: NSDate, toDate resultDate: NSDate, options opts: NSCalendarOptions) -> NSDateComponents {
+    public func components(_ unitFlags: NSCalendarUnit, from startingDate: NSDate, to resultDate: NSDate, options opts: NSCalendarOptions = []) -> NSDateComponents {
         let compDesc = _setup(unitFlags)
         var ints = [Int32](repeating: 0, count: 20)
         let res = ints.withUnsafeMutableBufferPointer { (intArrayBuffer: inout UnsafeMutableBufferPointer<Int32>) -> Bool in
@@ -573,8 +573,8 @@
     This API is a convenience for getting era, year, month, and day of a given date.
     Pass NULL for a NSInteger pointer parameter if you don't care about that value.
     */
-    public func getEra(_ eraValuePointer: UnsafeMutablePointer<Int>?, year yearValuePointer: UnsafeMutablePointer<Int>?, month monthValuePointer: UnsafeMutablePointer<Int>?, day dayValuePointer: UnsafeMutablePointer<Int>?, fromDate date: NSDate) {
-        if let comps = components([.Era, .Year, .Month, .Day], fromDate: date) {
+    public func getEra(_ eraValuePointer: UnsafeMutablePointer<Int>?, year yearValuePointer: UnsafeMutablePointer<Int>?, month monthValuePointer: UnsafeMutablePointer<Int>?, day dayValuePointer: UnsafeMutablePointer<Int>?, from date: NSDate) {
+        if let comps = components([.era, .year, .month, .day], from: date) {
             eraValuePointer?.pointee = comps.era
             yearValuePointer?.pointee = comps.year
             monthValuePointer?.pointee = comps.month
@@ -586,8 +586,8 @@
     This API is a convenience for getting era, year for week-of-year calculations, week of year, and weekday of a given date.
     Pass NULL for a NSInteger pointer parameter if you don't care about that value.
     */
-    public func getEra(_ eraValuePointer: UnsafeMutablePointer<Int>?, yearForWeekOfYear yearValuePointer: UnsafeMutablePointer<Int>?, weekOfYear weekValuePointer: UnsafeMutablePointer<Int>?, weekday weekdayValuePointer: UnsafeMutablePointer<Int>?, fromDate date: NSDate) {
-        if let comps = components([.Era, .YearForWeekOfYear, .WeekOfYear, .Weekday], fromDate: date) {
+    public func getEra(_ eraValuePointer: UnsafeMutablePointer<Int>?, yearForWeekOfYear yearValuePointer: UnsafeMutablePointer<Int>?, weekOfYear weekValuePointer: UnsafeMutablePointer<Int>?, weekday weekdayValuePointer: UnsafeMutablePointer<Int>?, from date: NSDate) {
+        if let comps = components([.era, .yearForWeekOfYear, .weekOfYear, .weekday], from: date) {
             eraValuePointer?.pointee = comps.era
             yearValuePointer?.pointee = comps.yearForWeekOfYear
             weekValuePointer?.pointee = comps.weekOfYear
@@ -599,8 +599,8 @@
     This API is a convenience for getting hour, minute, second, and nanoseconds of a given date.
     Pass NULL for a NSInteger pointer parameter if you don't care about that value.
     */
-    public func getHour(_ hourValuePointer: UnsafeMutablePointer<Int>?, minute minuteValuePointer: UnsafeMutablePointer<Int>?, second secondValuePointer: UnsafeMutablePointer<Int>?, nanosecond nanosecondValuePointer: UnsafeMutablePointer<Int>?, fromDate date: NSDate) {
-        if let comps = components([.Hour, .Minute, .Second, .Nanosecond], fromDate: date) {
+    public func getHour(_ hourValuePointer: UnsafeMutablePointer<Int>?, minute minuteValuePointer: UnsafeMutablePointer<Int>?, second secondValuePointer: UnsafeMutablePointer<Int>?, nanosecond nanosecondValuePointer: UnsafeMutablePointer<Int>?, from date: NSDate) {
+        if let comps = components([.hour, .minute, .second, .nanosecond], from: date) {
             hourValuePointer?.pointee = comps.hour
             minuteValuePointer?.pointee = comps.minute
             secondValuePointer?.pointee = comps.second
@@ -611,9 +611,9 @@
     /*
     Get just one component's value.
     */
-    public func component(_ unit: NSCalendarUnit, fromDate date: NSDate) -> Int {
-        let comps = components(unit, fromDate: date)
-        if let res = comps?.valueForComponent(unit) {
+    public func component(_ unit: NSCalendarUnit, from date: NSDate) -> Int {
+        let comps = components(unit, from: date)
+        if let res = comps?.value(forComponent: unit) {
             return res
         } else {
             return NSDateComponentUndefined
@@ -624,7 +624,7 @@
     Create a date with given components.
     Current era is assumed.
     */
-    public func dateWithEra(_ eraValue: Int, year yearValue: Int, month monthValue: Int, day dayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
+    public func date(era eraValue: Int, year yearValue: Int, month monthValue: Int, day dayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
         let comps = NSDateComponents()
         comps.era = eraValue
         comps.year = yearValue
@@ -634,14 +634,14 @@
         comps.minute = minuteValue
         comps.second = secondValue
         comps.nanosecond = nanosecondValue
-        return dateFromComponents(comps)
+        return date(from: comps)
     }
     
     /*
     Create a date with given components.
     Current era is assumed.
     */
-    public func dateWithEra(_ eraValue: Int, yearForWeekOfYear yearValue: Int, weekOfYear weekValue: Int, weekday weekdayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
+    public func date(era eraValue: Int, yearForWeekOfYear yearValue: Int, weekOfYear weekValue: Int, weekday weekdayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
         let comps = NSDateComponents()
         comps.era = eraValue
         comps.yearForWeekOfYear = yearValue
@@ -651,7 +651,7 @@
         comps.minute = minuteValue
         comps.second = secondValue
         comps.nanosecond = nanosecondValue
-        return dateFromComponents(comps)
+        return date(from: comps)
     }
     
     /*
@@ -659,8 +659,8 @@
     Pass in [NSDate date], for example, if you want the start of "today".
     If there were two midnights, it returns the first.  If there was none, it returns the first moment that did exist.
     */
-    public func startOfDayForDate(_ date: NSDate) -> NSDate {
-        return rangeOfUnit(.Day, forDate: date)!.start
+    public func startOfDay(for date: NSDate) -> NSDate {
+        return range(of: .day, forDate: date)!.start
     }
     
     /*
@@ -670,10 +670,10 @@
     */
     /// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
     /// The Darwin version is not nullable but this one is since the conversion from the date and unit flags can potentially return nil
-    public func componentsInTimeZone(_ timezone: NSTimeZone, fromDate date: NSDate) -> NSDateComponents? {
+    public func components(in timezone: NSTimeZone, fromDate date: NSDate) -> NSDateComponents? {
         let oldTz = self.timeZone
         self.timeZone = timezone
-        let comps = components([.Era, .Year, .Month, .Day, .Hour, .Minute, .Second, .Nanosecond, .Weekday, .WeekdayOrdinal, .Quarter, .WeekOfMonth, .WeekOfYear, .YearForWeekOfYear, .Calendar, .TimeZone], fromDate: date)
+        let comps = components([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .calendar, .timeZone], from: date)
         self.timeZone = oldTz
         return comps
     }
@@ -681,16 +681,16 @@
     /*
     This API compares the given dates down to the given unit, reporting them equal if they are the same in the given unit and all larger units, otherwise either less than or greater than.
     */
-    public func compareDate(_ date1: NSDate, toDate date2: NSDate, toUnitGranularity unit: NSCalendarUnit) -> NSComparisonResult {
+    public func compare(_ date1: NSDate, to date2: NSDate, toUnitGranularity unit: NSCalendarUnit) -> NSComparisonResult {
         switch (unit) {
-            case NSCalendarUnit.Calendar:
+            case NSCalendarUnit.calendar:
                 return .OrderedSame
-            case NSCalendarUnit.TimeZone:
+            case NSCalendarUnit.timeZone:
                 return .OrderedSame
-            case NSCalendarUnit.Day:
+            case NSCalendarUnit.day:
                 fallthrough
-            case NSCalendarUnit.Hour:
-                let range = rangeOfUnit(unit, forDate: date1)
+            case NSCalendarUnit.hour:
+                let range = self.range(of: unit, forDate: date1)
                 let ats = range!.start.timeIntervalSinceReferenceDate
                 let at2 = date2.timeIntervalSinceReferenceDate
                 if ats <= at2 && at2 < ats + range!.interval {
@@ -700,7 +700,7 @@
                     return .OrderedDescending
                 }
                 return .OrderedAscending
-            case NSCalendarUnit.Minute:
+            case NSCalendarUnit.minute:
                 var int1 = 0.0
                 var int2 = 0.0
                 modf(date1.timeIntervalSinceReferenceDate, &int1)
@@ -714,7 +714,7 @@
                     return .OrderedDescending
                 }
                 return .OrderedAscending
-            case NSCalendarUnit.Second:
+            case NSCalendarUnit.second:
                 var int1 = 0.0
                 var int2 = 0.0
                 modf(date1.timeIntervalSinceReferenceDate, &int1)
@@ -726,7 +726,7 @@
                     return .OrderedDescending
                 }
                 return .OrderedAscending
-            case NSCalendarUnit.Nanosecond:
+            case NSCalendarUnit.nanosecond:
                 var int1 = 0.0
                 var int2 = 0.0
                 let frac1 = modf(date1.timeIntervalSinceReferenceDate, &int1)
@@ -744,16 +744,16 @@
                 break
         }
 
-        let calendarUnits1: [NSCalendarUnit] = [.Era, .Year, .Month, .Day]
-        let calendarUnits2: [NSCalendarUnit] = [.Era, .Year, .Month, .WeekdayOrdinal, .Day]
-        let calendarUnits3: [NSCalendarUnit] = [.Era, .Year, .Month, .WeekOfMonth, .Weekday]
-        let calendarUnits4: [NSCalendarUnit] = [.Era, .YearForWeekOfYear, .WeekOfYear, .Weekday]
+        let calendarUnits1: [NSCalendarUnit] = [.era, .year, .month, .day]
+        let calendarUnits2: [NSCalendarUnit] = [.era, .year, .month, .weekdayOrdinal, .day]
+        let calendarUnits3: [NSCalendarUnit] = [.era, .year, .month, .weekOfMonth, .weekday]
+        let calendarUnits4: [NSCalendarUnit] = [.era, .yearForWeekOfYear, .weekOfYear, .weekday]
         var units: [NSCalendarUnit]
-        if unit == .YearForWeekOfYear || unit == .WeekOfYear {
+        if unit == .yearForWeekOfYear || unit == .weekOfYear {
             units = calendarUnits4
-        } else if unit == .WeekdayOrdinal {
+        } else if unit == .weekdayOrdinal {
             units = calendarUnits2
-        } else if unit == .Weekday || unit == .WeekOfMonth {
+        } else if unit == .weekday || unit == .weekOfMonth {
             units = calendarUnits3
         } else {
             units = calendarUnits1
@@ -761,18 +761,18 @@
         
         // TODO: verify that the return value here is never going to be nil; it seems like it may - thusly making the return value here optional which would result in sadness and regret
         let reducedUnits = units.reduce(NSCalendarUnit()) { $0.union($1) }
-        let comp1 = components(reducedUnits, fromDate: date1)!
-        let comp2 = components(reducedUnits, fromDate: date2)!
+        let comp1 = components(reducedUnits, from: date1)!
+        let comp2 = components(reducedUnits, from: date2)!
     
         for unit in units {
-            let value1 = comp1.valueForComponent(unit)
-            let value2 = comp2.valueForComponent(unit)
+            let value1 = comp1.value(forComponent: unit)
+            let value2 = comp2.value(forComponent: unit)
             if value1 > value2 {
                 return .OrderedDescending
             } else if value1 < value2 {
                 return .OrderedAscending
             }
-            if unit == .Month && calendarIdentifier == kCFCalendarIdentifierChinese._swiftObject {
+            if unit == .month && calendarIdentifier == kCFCalendarIdentifierChinese._swiftObject {
                 let leap1 = comp1.leapMonth
                 let leap2 = comp2.leapMonth
                 if !leap1 && leap2 {
@@ -792,30 +792,30 @@
     This API compares the given dates down to the given unit, reporting them equal if they are the same in the given unit and all larger units.
     */
     public func isDate(_ date1: NSDate, equalToDate date2: NSDate, toUnitGranularity unit: NSCalendarUnit) -> Bool {
-        return compareDate(date1, toDate: date2, toUnitGranularity: unit) == .OrderedSame
+        return compare(date1, to: date2, toUnitGranularity: unit) == .OrderedSame
     }
     
     /*
     This API compares the Days of the given dates, reporting them equal if they are in the same Day.
     */
     public func isDate(_ date1: NSDate, inSameDayAsDate date2: NSDate) -> Bool {
-        return compareDate(date1, toDate: date2, toUnitGranularity: .Day) == .OrderedSame
+        return compare(date1, to: date2, toUnitGranularity: .day) == .OrderedSame
     }
     
     /*
     This API reports if the date is within "today".
     */
     public func isDateInToday(_ date: NSDate) -> Bool {
-        return compareDate(date, toDate: NSDate(), toUnitGranularity: .Day) == .OrderedSame
+        return compare(date, to: NSDate(), toUnitGranularity: .day) == .OrderedSame
     }
     
     /*
     This API reports if the date is within "yesterday".
     */
     public func isDateInYesterday(_ date: NSDate) -> Bool {
-        if let interval = rangeOfUnit(.Day, forDate: NSDate()) {
+        if let interval = range(of: .day, forDate: NSDate()) {
             let inYesterday = interval.start.addingTimeInterval(-60.0)
-            return compareDate(date, toDate: inYesterday, toUnitGranularity: .Day) == .OrderedSame
+            return compare(date, to: inYesterday, toUnitGranularity: .day) == .OrderedSame
         } else {
             return false
         }
@@ -825,9 +825,9 @@
     This API reports if the date is within "tomorrow".
     */
     public func isDateInTomorrow(_ date: NSDate) -> Bool {
-        if let interval = rangeOfUnit(.Day, forDate: NSDate()) {
+        if let interval = range(of: .day, forDate: NSDate()) {
             let inTomorrow = interval.end.addingTimeInterval(60.0)
-            return compareDate(date, toDate: inTomorrow, toUnitGranularity: .Day) == .OrderedSame
+            return compare(date, to: inTomorrow, toUnitGranularity: .day) == .OrderedSame
         } else {
             return false
         }
@@ -851,7 +851,7 @@
     /// - Note: Since this API is under consideration it may be either removed or revised in the near future
     public func rangeOfWeekendContaining(_ date: NSDate) -> NSDateInterval? {
         if let next = nextWeekendAfter(date, options: []) {
-            if let prev = nextWeekendAfter(next.start, options: .SearchBackwards) {
+            if let prev = nextWeekendAfter(next.start, options: .searchBackwards) {
                 if prev.start.timeIntervalSinceReferenceDate <= date.timeIntervalSinceReferenceDate && date.timeIntervalSinceReferenceDate <= prev.end.timeIntervalSinceReferenceDate {
                     return prev
                 }
@@ -877,13 +877,13 @@
         if res {
             let comp = NSDateComponents()
             comp.weekday = range.start
-            if let nextStart = nextDateAfterDate(date, matchingComponents: comp, options: options.union(.MatchNextTime)) {
+            if let nextStart = nextDate(after: date, matchingComponents: comp, options: options.union(.matchNextTime)) {
                 let start = nextStart.addingTimeInterval(range.onsetTime)
                 comp.weekday = range.end
-                if let nextEnd = nextDateAfterDate(date, matchingComponents: comp, options: options.union(.MatchNextTime)) {
+                if let nextEnd = nextDate(after: date, matchingComponents: comp, options: options.union(.matchNextTime)) {
                     var end = nextEnd
                     if end.compare(start) == .OrderedAscending {
-                        if let nextOrderedEnd = nextDateAfterDate(end, matchingComponents: comp, options: options.union(.MatchNextTime)) {
+                        if let nextOrderedEnd = nextDate(after: end, matchingComponents: comp, options: options.union(.matchNextTime)) {
                             end = nextOrderedEnd
                         } else {
                             return nil
@@ -892,8 +892,8 @@
                     if range.ceaseTime > 0 {
                         end = end.addingTimeInterval(range.ceaseTime)
                     } else {
-                        if let dayEnd = rangeOfUnit(.Day, forDate: end) {
-                            end = startOfDayForDate(dayEnd.end)
+                        if let dayEnd = self.range(of: .day, forDate: end) {
+                            end = startOfDay(for: dayEnd.end)
                         } else {
                             return nil
                         }
@@ -912,22 +912,22 @@
     For each date components object, if its time zone property is set, that time zone is used for it; if the calendar property is set, that is used rather than the receiving calendar, and if both the calendar and time zone are set, the time zone property value overrides the time zone of the calendar property.
     No options are currently defined; pass 0.
     */
-    public func components(_ unitFlags: NSCalendarUnit, fromDateComponents startingDateComp: NSDateComponents, toDateComponents resultDateComp: NSDateComponents, options: NSCalendarOptions) -> NSDateComponents? {
+    public func components(_ unitFlags: NSCalendarUnit, from startingDateComp: NSDateComponents, to resultDateComp: NSDateComponents, options: NSCalendarOptions = []) -> NSDateComponents? {
         var startDate: NSDate?
         var toDate: NSDate?
         if let startCalendar = startingDateComp.calendar {
-            startDate = startCalendar.dateFromComponents(startingDateComp)
+            startDate = startCalendar.date(from: startingDateComp)
         } else {
-            startDate = dateFromComponents(startingDateComp)
+            startDate = date(from: startingDateComp)
         }
         if let toCalendar = resultDateComp.calendar {
-            toDate = toCalendar.dateFromComponents(resultDateComp)
+            toDate = toCalendar.date(from: resultDateComp)
         } else {
-            toDate = dateFromComponents(resultDateComp)
+            toDate = date(from: resultDateComp)
         }
         if let start = startDate {
             if let end = toDate {
-                return components(unitFlags, fromDate: start, toDate: end, options: options)
+                return components(unitFlags, from: start, to: end, options: options)
             }
         }
         return nil
@@ -937,10 +937,10 @@
     This API returns a new NSDate object representing the date calculated by adding an amount of a specific component to a given date.
     The NSCalendarWrapComponents option specifies if the component should be incremented and wrap around to zero/one on overflow, and should not cause higher units to be incremented.
     */
-    public func dateByAddingUnit(_ unit: NSCalendarUnit, value: Int, toDate date: NSDate, options: NSCalendarOptions) -> NSDate? {
+    public func date(byAdding unit: NSCalendarUnit, value: Int, to date: NSDate, options: NSCalendarOptions = []) -> NSDate? {
         let comps = NSDateComponents()
         comps.setValue(value, forComponent: unit)
-        return dateByAddingComponents(comps, toDate: date, options: options)
+        return self.date(byAdding: comps, to: date, options: options)
     }
     
     /*
@@ -965,16 +965,16 @@
     Result dates have an integer number of seconds (as if 0 was specified for the nanoseconds property of the NSDateComponents matching parameter), unless a value was set in the nanoseconds property, in which case the result date will have that number of nanoseconds (or as close as possible with floating point numbers).
     The enumeration is stopped by setting *stop = YES in the block and return.  It is not necessary to set *stop to NO to keep the enumeration going.
     */
-    public func enumerateDatesStartingAfterDate(_ start: NSDate, matchingComponents comps: NSDateComponents, options opts: NSCalendarOptions, usingBlock block: (NSDate?, Bool, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
+    public func enumerateDates(startingAfter start: NSDate, matchingComponents comps: NSDateComponents, options opts: NSCalendarOptions = [], usingBlock block: (NSDate?, Bool, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
     
     /*
     This method computes the next date which matches (or most closely matches) a given set of components.
     The general semantics follow those of the -enumerateDatesStartingAfterDate:... method above.
     To compute a sequence of results, use the -enumerateDatesStartingAfterDate:... method above, rather than looping and calling this method with the previous loop iteration's result.
     */
-    public func nextDateAfterDate(_ date: NSDate, matchingComponents comps: NSDateComponents, options: NSCalendarOptions) -> NSDate? {
+    public func nextDate(after date: NSDate, matchingComponents comps: NSDateComponents, options: NSCalendarOptions = []) -> NSDate? {
         var result: NSDate?
-        enumerateDatesStartingAfterDate(date, matchingComponents: comps, options: options) { date, exactMatch, stop in
+        enumerateDates(startingAfter: date, matchingComponents: comps, options: options) { date, exactMatch, stop in
             result = date
             stop.pointee = true
         }
@@ -986,10 +986,10 @@
     The general semantics follow those of the -enumerateDatesStartingAfterDate:... method above.
     To compute a sequence of results, use the -enumerateDatesStartingAfterDate:... method above, rather than looping and calling this method with the previous loop iteration's result.
     */
-    public func nextDateAfterDate(_ date: NSDate, matchingUnit unit: NSCalendarUnit, value: Int, options: NSCalendarOptions) -> NSDate? {
+    public func nextDate(after date: NSDate, matchingUnit unit: NSCalendarUnit, value: Int, options: NSCalendarOptions = []) -> NSDate? {
         let comps = NSDateComponents()
         comps.setValue(value, forComponent: unit)
-        return nextDateAfterDate(date, matchingComponents: comps, options: options)
+        return nextDate(after:date, matchingComponents: comps, options: options)
     }
     
     /*
@@ -997,12 +997,12 @@
     The general semantics follow those of the -enumerateDatesStartingAfterDate:... method above.
     To compute a sequence of results, use the -enumerateDatesStartingAfterDate:... method above, rather than looping and calling this method with the previous loop iteration's result.
     */
-    public func nextDateAfterDate(_ date: NSDate, matchingHour hourValue: Int, minute minuteValue: Int, second secondValue: Int, options: NSCalendarOptions) -> NSDate? {
+    public func nextDate(after date: NSDate, matchingHour hourValue: Int, minute minuteValue: Int, second secondValue: Int, options: NSCalendarOptions = []) -> NSDate? {
         let comps = NSDateComponents()
         comps.hour = hourValue
         comps.minute = minuteValue
         comps.second = secondValue
-        return nextDateAfterDate(date, matchingComponents: comps, options: options)
+        return nextDate(after: date, matchingComponents: comps, options: options)
     }
     
     /*
@@ -1011,15 +1011,15 @@
     If no such time exists, the next available time is returned (which could, for example, be in a different day, week, month, ... than the nominal target date).  Setting a component to something which would be inconsistent forces other units to change; for example, setting the Weekday to Thursday probably shifts the Day and possibly Month and Year.
     The specific behaviors here are as yet unspecified; for example, if I change the weekday to Thursday, does that move forward to the next, backward to the previous, or to the nearest Thursday?  A likely rule is that the algorithm will try to produce a result which is in the next-larger unit to the one given (there's a table of this mapping at the top of this document).  So for the "set to Thursday" example, find the Thursday in the Week in which the given date resides (which could be a forwards or backwards move, and not necessarily the nearest Thursday).  For forwards or backwards behavior, one can use the -nextDateAfterDate:matchingUnit:value:options: method above.
     */
-    public func dateBySettingUnit(_ unit: NSCalendarUnit, value v: Int, ofDate date: NSDate, options opts: NSCalendarOptions) -> NSDate? {
-        let currentValue = component(unit, fromDate: date)
+    public func date(bySettingUnit unit: NSCalendarUnit, value v: Int, ofDate date: NSDate, options opts: NSCalendarOptions = []) -> NSDate? {
+        let currentValue = component(unit, from: date)
         if currentValue == v {
             return date
         }
         let targetComp = NSDateComponents()
         targetComp.setValue(v, forComponent: unit)
         var result: NSDate?
-        enumerateDatesStartingAfterDate(date, matchingComponents: targetComp, options: .MatchNextTime) { date, match, stop in
+        enumerateDates(startingAfter: date, matchingComponents: targetComp, options: .matchNextTime) { date, match, stop in
             result = date
             stop.pointee = true
         }
@@ -1031,20 +1031,20 @@
     If no such time exists, the next available time is returned (which could, for example, be in a different day than the nominal target date).
     The intent is to return a date on the same day as the original date argument.  This may result in a date which is earlier than the given date, of course.
     */
-    public func dateBySettingHour(_ h: Int, minute m: Int, second s: Int, ofDate date: NSDate, options opts: NSCalendarOptions) -> NSDate? {
-        if let range = rangeOfUnit(.Day, forDate: date) {
+    public func date(bySettingHour h: Int, minute m: Int, second s: Int, ofDate date: NSDate, options opts: NSCalendarOptions = []) -> NSDate? {
+        if let range = range(of: .day, forDate: date) {
             let comps = NSDateComponents()
             comps.hour = h
             comps.minute = m
             comps.second = s
-            var options: NSCalendarOptions = .MatchNextTime
-            options.unionInPlace(opts.contains(.MatchLast) ? .MatchLast : .MatchFirst)
-            if opts.contains(.MatchStrictly) {
-                options.unionInPlace(.MatchStrictly)
+            var options: NSCalendarOptions = .matchNextTime
+            options.formUnion(opts.contains(.matchLast) ? .matchLast : .matchFirst)
+            if opts.contains(.matchStrictly) {
+                options.formUnion(.matchStrictly)
             }
-            if let result = nextDateAfterDate(range.start.addingTimeInterval(-0.5), matchingComponents: comps, options: options) {
+            if let result = nextDate(after: range.start.addingTimeInterval(-0.5), matchingComponents: comps, options: options) {
                 if result.compare(range.start) == .OrderedAscending {
-                    return nextDateAfterDate(range.start, matchingComponents: comps, options: options)
+                    return nextDate(after: range.start, matchingComponents: comps, options: options)
                 }
                 return result
             }
@@ -1058,29 +1058,29 @@
     It is useful to test the return value of the -nextDateAfterDate:matchingUnit:value:options:, to find out if the components were obeyed or if the method had to fudge the result value due to missing time.
     */
     public func date(_ date: NSDate, matchesComponents components: NSDateComponents) -> Bool {
-        let units: [NSCalendarUnit] = [.Era, .Year, .Month, .Day, .Hour, .Minute, .Second, .Weekday, .WeekdayOrdinal, .Quarter, .WeekOfMonth, .WeekOfYear, .YearForWeekOfYear, .Nanosecond]
+        let units: [NSCalendarUnit] = [.era, .year, .month, .day, .hour, .minute, .second, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .nanosecond]
         var unitFlags: NSCalendarUnit = []
         for unit in units {
-            if components.valueForComponent(unit) != NSDateComponentUndefined {
-                unitFlags.unionInPlace(unit)
+            if components.value(forComponent: unit) != NSDateComponentUndefined {
+                unitFlags.formUnion(unit)
             }
         }
         if unitFlags == [] {
             if components.leapMonthSet {
-                if let comp = self.components(.Month, fromDate: date) {
+                if let comp = self.components(.month, from: date) {
                     return comp.leapMonth
                 }
                 return false
             }
         }
-        if let comp = self.components(unitFlags, fromDate: date) {
+        if let comp = self.components(unitFlags, from: date) {
             let tempComp = components.copy() as! NSDateComponents
             if comp.leapMonthSet && !components.leapMonthSet {
                 tempComp.leapMonth = comp.leapMonth
             }
-            let nanosecond = comp.valueForComponent(.Nanosecond)
+            let nanosecond = comp.value(forComponent: .nanosecond)
             if nanosecond != NSDateComponentUndefined {
-                if labs(nanosecond - tempComp.valueForComponent(.Nanosecond)) > 500 {
+                if labs(nanosecond - tempComp.value(forComponent: .nanosecond)) > 500 {
                     return false
                 } else {
                     comp.nanosecond = 0
@@ -1462,7 +1462,7 @@
         if let tz = timeZone {
             calendar?.timeZone = tz
         }
-        return calendar?.dateFromComponents(self)
+        return calendar?.date(from: self)
     }
     
     /*
@@ -1471,52 +1471,52 @@
     */
     public func setValue(_ value: Int, forComponent unit: NSCalendarUnit) {
         switch unit {
-            case NSCalendarUnit.Era:
+            case NSCalendarUnit.era:
                 era = value
                 break
-            case NSCalendarUnit.Year:
+            case NSCalendarUnit.year:
                 year = value
                 break
-            case NSCalendarUnit.Month:
+            case NSCalendarUnit.month:
                 month = value
                 break
-            case NSCalendarUnit.Day:
+            case NSCalendarUnit.day:
                 day = value
                 break
-            case NSCalendarUnit.Hour:
+            case NSCalendarUnit.hour:
                 hour = value
                 break
-            case NSCalendarUnit.Minute:
+            case NSCalendarUnit.minute:
                 minute = value
                 break
-            case NSCalendarUnit.Second:
+            case NSCalendarUnit.second:
                 second = value
                 break
-            case NSCalendarUnit.Nanosecond:
+            case NSCalendarUnit.nanosecond:
                 nanosecond = value
                 break
-            case NSCalendarUnit.Weekday:
+            case NSCalendarUnit.weekday:
                 weekday = value
                 break
-            case NSCalendarUnit.WeekdayOrdinal:
+            case NSCalendarUnit.weekdayOrdinal:
                 weekdayOrdinal = value
                 break
-            case NSCalendarUnit.Quarter:
+            case NSCalendarUnit.quarter:
                 quarter = value
                 break
-            case NSCalendarUnit.WeekOfMonth:
+            case NSCalendarUnit.weekOfMonth:
                 weekOfMonth = value
                 break
-            case NSCalendarUnit.WeekOfYear:
+            case NSCalendarUnit.weekOfYear:
                 weekOfYear = value
                 break
-            case NSCalendarUnit.YearForWeekOfYear:
+            case NSCalendarUnit.yearForWeekOfYear:
                 yearForWeekOfYear = value
                 break
-            case NSCalendarUnit.Calendar:
+            case NSCalendarUnit.calendar:
                 print(".Calendar cannot be set via \(#function)")
                 break
-            case NSCalendarUnit.TimeZone:
+            case NSCalendarUnit.timeZone:
                 print(".TimeZone cannot be set via \(#function)")
                 break
             default:
@@ -1528,35 +1528,35 @@
     This API allows one to get the value of a specific component of NSDateComponents, by enum constant value rather than property name.
     The calendar and timeZone and isLeapMonth property values cannot be gotten by this method.
     */
-    public func valueForComponent(_ unit: NSCalendarUnit) -> Int {
+    public func value(forComponent unit: NSCalendarUnit) -> Int {
         switch unit {
-            case NSCalendarUnit.Era:
+            case NSCalendarUnit.era:
                 return era
-            case NSCalendarUnit.Year:
+            case NSCalendarUnit.year:
                 return year
-            case NSCalendarUnit.Month:
+            case NSCalendarUnit.month:
                 return month
-            case NSCalendarUnit.Day:
+            case NSCalendarUnit.day:
                 return day
-            case NSCalendarUnit.Hour:
+            case NSCalendarUnit.hour:
                 return hour
-            case NSCalendarUnit.Minute:
+            case NSCalendarUnit.minute:
                 return minute
-            case NSCalendarUnit.Second:
+            case NSCalendarUnit.second:
                 return second
-            case NSCalendarUnit.Nanosecond:
+            case NSCalendarUnit.nanosecond:
                 return nanosecond
-            case NSCalendarUnit.Weekday:
+            case NSCalendarUnit.weekday:
                 return weekday
-            case NSCalendarUnit.WeekdayOrdinal:
+            case NSCalendarUnit.weekdayOrdinal:
                 return weekdayOrdinal
-            case NSCalendarUnit.Quarter:
+            case NSCalendarUnit.quarter:
                 return quarter
-            case NSCalendarUnit.WeekOfMonth:
+            case NSCalendarUnit.weekOfMonth:
                 return weekOfMonth
-            case NSCalendarUnit.WeekOfYear:
+            case NSCalendarUnit.weekOfYear:
                 return weekOfYear
-            case NSCalendarUnit.YearForWeekOfYear:
+            case NSCalendarUnit.yearForWeekOfYear:
                 return yearForWeekOfYear
             default:
                 break
@@ -1573,7 +1573,7 @@
     */
     public var validDate: Bool {
         if let cal = calendar {
-            return isValidDateInCalendar(cal)
+            return isValidDate(in: cal)
         }
         return false
     }
@@ -1584,7 +1584,7 @@
     Except for some trivial cases (e.g., 'seconds' should be 0 - 59 in any calendar), this method is not necessarily cheap.
     If the time zone property is set in the NSDateComponents object, it is used.
     */
-    public func isValidDateInCalendar(_ calendar: NSCalendar) -> Bool {
+    public func isValidDate(in calendar: NSCalendar) -> Bool {
         let cal = calendar.copy() as! NSCalendar
         if let tz = timeZone {
             cal.timeZone = tz
@@ -1596,13 +1596,13 @@
         if ns != NSDateComponentUndefined && 0 < ns {
             nanosecond = 0
         }
-        let d = calendar.dateFromComponents(self)
+        let d = calendar.date(from: self)
         if ns != NSDateComponentUndefined && 0 < ns {
             nanosecond = ns
         }
         if let date = d {
-            let all: NSCalendarUnit = [.Era, .Year, .Month, .Day, .Hour, .Minute, .Second, .Weekday, .WeekdayOrdinal, .Quarter, .WeekOfMonth, .WeekOfYear, .YearForWeekOfYear]
-            if let comps = calendar.components(all, fromDate: date) {
+            let all: NSCalendarUnit = [.era, .year, .month, .day, .hour, .minute, .second, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear]
+            if let comps = calendar.components(all, from: date) {
                 var val = era
                 if val != NSDateComponentUndefined {
                     if comps.era != val {
@@ -1700,4 +1700,3 @@
     typealias NSType = NSCalendar
     internal var _nsObject: NSType { return unsafeBitCast(self, to: NSType.self) }
 }
-
diff --git a/Foundation/NSCharacterSet.swift b/Foundation/NSCharacterSet.swift
index c0d49dc..e52fc19 100644
--- a/Foundation/NSCharacterSet.swift
+++ b/Foundation/NSCharacterSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -65,63 +65,63 @@
         _CFDeinit(self)
     }
     
-    public class func controlCharacterSet() -> NSCharacterSet {
+    public class func controlCharacters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetControl)._nsObject
     }
     
-    public class func whitespaceCharacterSet() -> NSCharacterSet {
+    public class func whitespaces() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetWhitespace)._nsObject
     }
 
-    public class func whitespaceAndNewlineCharacterSet() -> NSCharacterSet {
+    public class func whitespacesAndNewlines() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline)._nsObject
     }
     
-    public class func decimalDigitCharacterSet() -> NSCharacterSet {
+    public class func decimalDigits() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit)._nsObject
     }
     
-    public class func letterCharacterSet() -> NSCharacterSet {
+    public class func letters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetLetter)._nsObject
     }
     
-    public class func lowercaseLetterCharacterSet() -> NSCharacterSet {
+    public class func lowercaseLetters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter)._nsObject
     }
     
-    public class func uppercaseLetterCharacterSet() -> NSCharacterSet {
+    public class func uppercaseLetters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter)._nsObject
     }
     
-    public class func nonBaseCharacterSet() -> NSCharacterSet {
+    public class func nonBaseCharacters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetNonBase)._nsObject
     }
     
-    public class func alphanumericCharacterSet() -> NSCharacterSet {
+    public class func alphanumerics() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric)._nsObject
     }
     
-    public class func decomposableCharacterSet() -> NSCharacterSet {
+    public class func decomposables() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetDecomposable)._nsObject
     }
     
-    public class func illegalCharacterSet() -> NSCharacterSet {
+    public class func illegalCharacters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetIllegal)._nsObject
     }
     
-    public class func punctuationCharacterSet() -> NSCharacterSet {
+    public class func punctuation() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetPunctuation)._nsObject
     }
     
-    public class func capitalizedLetterCharacterSet() -> NSCharacterSet {
+    public class func capitalizedLetters() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetCapitalizedLetter)._nsObject
     }
     
-    public class func symbolCharacterSet() -> NSCharacterSet {
+    public class func symbols() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetSymbol)._nsObject
     }
     
-    public class func newlineCharacterSet() -> NSCharacterSet {
+    public class func newlines() -> NSCharacterSet {
         return CFCharacterSetGetPredefined(kCFCharacterSetNewline)._nsObject
     }
 
@@ -130,7 +130,7 @@
         _CFCharacterSetInitWithCharactersInRange(_cfMutableObject, CFRangeMake(aRange.location, aRange.length))
     }
     
-    public init(charactersInString aString: String) {
+    public init(charactersIn aString: String) {
         super.init()
         _CFCharacterSetInitWithCharactersInString(_cfMutableObject, aString._cfObject)
     }
@@ -149,7 +149,7 @@
     }
     
     public convenience required init(coder aDecoder: NSCoder) {
-        self.init(charactersInString: "")
+        self.init(charactersIn: "")
     }
     
     public func characterIsMember(_ aCharacter: unichar) -> Bool {
@@ -203,27 +203,27 @@
         NSUnimplemented()
     }
     
-    public func addCharactersInRange(_ aRange: NSRange) {
+    public func addCharacters(in aRange: NSRange) {
         CFCharacterSetAddCharactersInRange(_cfMutableObject , CFRangeMake(aRange.location, aRange.length))
     }
     
-    public func removeCharactersInRange(_ aRange: NSRange) {
+    public func removeCharacters(in aRange: NSRange) {
         CFCharacterSetRemoveCharactersInRange(_cfMutableObject , CFRangeMake(aRange.location, aRange.length))
     }
     
-    public func addCharactersInString(_ aString: String) {
+    public func addCharacters(in aString: String) {
         CFCharacterSetAddCharactersInString(_cfMutableObject, aString._cfObject)
     }
     
-    public func removeCharactersInString(_ aString: String) {
+    public func removeCharacters(in aString: String) {
         CFCharacterSetRemoveCharactersInString(_cfMutableObject, aString._cfObject)
     }
     
-    public func formUnionWithCharacterSet(_ otherSet: NSCharacterSet) {
+    public func formUnion(with otherSet: NSCharacterSet) {
         CFCharacterSetUnion(_cfMutableObject, otherSet._cfObject)
     }
     
-    public func formIntersectionWithCharacterSet(_ otherSet: NSCharacterSet) {
+    public func formIntersection(with otherSet: NSCharacterSet) {
         CFCharacterSetIntersect(_cfMutableObject, otherSet._cfObject)
     }
     
@@ -231,64 +231,64 @@
         CFCharacterSetInvert(_cfMutableObject)
     }
 
-    public override class func controlCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.controlCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func controlCharacters() -> NSMutableCharacterSet {
+        return NSCharacterSet.controlCharacters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func whitespaceCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.whitespaceCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func whitespaces() -> NSMutableCharacterSet {
+        return NSCharacterSet.whitespaces().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func whitespaceAndNewlineCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.whitespaceAndNewlineCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func whitespacesAndNewlines() -> NSMutableCharacterSet {
+        return NSCharacterSet.whitespacesAndNewlines().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func decimalDigitCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.decimalDigitCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func decimalDigits() -> NSMutableCharacterSet {
+        return NSCharacterSet.decimalDigits().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func letterCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.letterCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func letters() -> NSMutableCharacterSet {
+        return NSCharacterSet.letters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func lowercaseLetterCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.lowercaseLetterCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func lowercaseLetters() -> NSMutableCharacterSet {
+        return NSCharacterSet.lowercaseLetters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func uppercaseLetterCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.uppercaseLetterCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func uppercaseLetters() -> NSMutableCharacterSet {
+        return NSCharacterSet.uppercaseLetters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func nonBaseCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.nonBaseCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func nonBaseCharacters() -> NSMutableCharacterSet {
+        return NSCharacterSet.nonBaseCharacters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func alphanumericCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.alphanumericCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func alphanumerics() -> NSMutableCharacterSet {
+        return NSCharacterSet.alphanumerics().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func decomposableCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.decomposableCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func decomposables() -> NSMutableCharacterSet {
+        return NSCharacterSet.decomposables().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func illegalCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.illegalCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func illegalCharacters() -> NSMutableCharacterSet {
+        return NSCharacterSet.illegalCharacters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func punctuationCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.punctuationCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func punctuation() -> NSMutableCharacterSet {
+        return NSCharacterSet.punctuation().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func capitalizedLetterCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.capitalizedLetterCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func capitalizedLetters() -> NSMutableCharacterSet {
+        return NSCharacterSet.capitalizedLetters().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func symbolCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.symbolCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func symbols() -> NSMutableCharacterSet {
+        return NSCharacterSet.symbols().mutableCopy() as! NSMutableCharacterSet
     }
     
-    public override class func newlineCharacterSet() -> NSMutableCharacterSet {
-        return NSCharacterSet.newlineCharacterSet().mutableCopy() as! NSMutableCharacterSet
+    public override class func newlines() -> NSMutableCharacterSet {
+        return NSCharacterSet.newlines().mutableCopy() as! NSMutableCharacterSet
     }
 }
 
diff --git a/Foundation/NSCoder.swift b/Foundation/NSCoder.swift
index 2e753a4..9a62419 100644
--- a/Foundation/NSCoder.swift
+++ b/Foundation/NSCoder.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSComparisonPredicate.swift b/Foundation/NSComparisonPredicate.swift
index 0843b82..4b4d97a 100644
--- a/Foundation/NSComparisonPredicate.swift
+++ b/Foundation/NSComparisonPredicate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSCompoundPredicate.swift b/Foundation/NSCompoundPredicate.swift
index 3f17574..fb46180 100644
--- a/Foundation/NSCompoundPredicate.swift
+++ b/Foundation/NSCompoundPredicate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSConcreteValue.swift b/Foundation/NSConcreteValue.swift
index 9385a2d..3d1a52b 100644
--- a/Foundation/NSConcreteValue.swift
+++ b/Foundation/NSConcreteValue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -105,7 +105,7 @@
     }
     
     override var objCType : UnsafePointer<Int8> {
-        return NSString(self._typeInfo.name).UTF8String! // XXX leaky
+        return NSString(self._typeInfo.name).utf8String! // XXX leaky
     }
     
     override var classForCoder: AnyClass {
diff --git a/Foundation/NSData.swift b/Foundation/NSData.swift
index 1b64da6..c5ddb18 100644
--- a/Foundation/NSData.swift
+++ b/Foundation/NSData.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -539,7 +539,7 @@
         }
         return location.map {NSRange(location: $0, length: search.count)} ?? NSRange(location: NSNotFound, length: 0)
     }
-    private static func searchSubSequence<T : Collection,T2 : Sequence where T.Iterator.Element : Equatable, T.Iterator.Element == T2.Iterator.Element, T.SubSequence.Iterator.Element == T.Iterator.Element>(_ subSequence : T2, inSequence seq: T,anchored : Bool) -> T.Index? {
+    private static func searchSubSequence<T : Collection, T2 : Sequence where T.Iterator.Element : Equatable, T.Iterator.Element == T2.Iterator.Element, T.SubSequence.Iterator.Element == T.Iterator.Element, T.Indices.Iterator.Element == T.Index>(_ subSequence : T2, inSequence seq: T,anchored : Bool) -> T.Index? {
         for index in seq.indices {
             if seq.suffix(from: index).starts(with: subSequence) {
                 return index
@@ -684,10 +684,10 @@
         var decodedStart: UInt8 = 0
         for range in base64ByteMappings {
             if range.contains(byte) {
-                let result = decodedStart + (byte - range.startIndex)
+                let result = decodedStart + (byte - range.lowerBound)
                 return .Valid(result)
             }
-            decodedStart += range.endIndex - range.startIndex
+            decodedStart += range.upperBound - range.lowerBound
         }
         return .Invalid
     }
@@ -706,11 +706,11 @@
         assert(byte < 64)
         var decodedStart: UInt8 = 0
         for range in base64ByteMappings {
-            let decodedRange = decodedStart ..< decodedStart + (range.endIndex - range.startIndex)
+            let decodedRange = decodedStart ..< decodedStart + (range.upperBound - range.lowerBound)
             if decodedRange.contains(byte) {
-                return range.startIndex + (byte - decodedStart)
+                return range.lowerBound + (byte - decodedStart)
             }
-            decodedStart += range.endIndex - range.startIndex
+            decodedStart += range.upperBound - range.lowerBound
         }
         return 0
     }
diff --git a/Foundation/NSDate.swift b/Foundation/NSDate.swift
index c2c3547..6f43821 100644
--- a/Foundation/NSDate.swift
+++ b/Foundation/NSDate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDateComponentsFormatter.swift b/Foundation/NSDateComponentsFormatter.swift
index 8d8f530..9998b98 100644
--- a/Foundation/NSDateComponentsFormatter.swift
+++ b/Foundation/NSDateComponentsFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDateFormatter.swift b/Foundation/NSDateFormatter.swift
index 8b7dc7b..5aec319 100644
--- a/Foundation/NSDateFormatter.swift
+++ b/Foundation/NSDateFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDateIntervalFormatter.swift b/Foundation/NSDateIntervalFormatter.swift
index 18b4d61..14b6bbf 100644
--- a/Foundation/NSDateIntervalFormatter.swift
+++ b/Foundation/NSDateIntervalFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDecimal.swift b/Foundation/NSDecimal.swift
index 5ccebe1..4d179d3 100644
--- a/Foundation/NSDecimal.swift
+++ b/Foundation/NSDecimal.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDecimalNumber.swift b/Foundation/NSDecimalNumber.swift
index 1abeda0..d014095 100644
--- a/Foundation/NSDecimalNumber.swift
+++ b/Foundation/NSDecimalNumber.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSDictionary.swift b/Foundation/NSDictionary.swift
index f60cf55..319094a 100644
--- a/Foundation/NSDictionary.swift
+++ b/Foundation/NSDictionary.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -41,17 +41,12 @@
         
         if x.dynamicType == NSDictionary.self || x.dynamicType == NSMutableDictionary.self {
             x.enumerateKeysAndObjectsUsingBlock { key, value, stop in
-                if let k = key as? Key {
-                    if let v = value as? Value {
-                        dict[k] = v
-                    } else {
-                        failedConversion = true
-                        stop.pointee = true
-                    }
-                } else {
+                guard let key = key as? Key, let value = value as? Value else {
                     failedConversion = true
                     stop.pointee = true
+                    return
                 }
+                dict[key] = value
             }
         } else if x.dynamicType == _NSCFDictionary.self {
             let cf = x._cfObject
@@ -65,17 +60,11 @@
             for idx in 0..<cnt {
                 let key = unsafeBitCast(keys.advanced(by: idx).pointee!, to: AnyObject.self)
                 let value = unsafeBitCast(values.advanced(by: idx).pointee!, to: AnyObject.self)
-                if let k = key as? Key {
-                    if let v = value as? Value {
-                        dict[k] = v
-                    } else {
-                        failedConversion = true
-                        break
-                    }
-                } else {
+                guard let k = key as? Key, let v = value as? Value else {
                     failedConversion = true
                     break
                 }
+                dict[k] = v
             }
             keys.deinitialize(count: cnt)
             values.deinitialize(count: cnt)
@@ -255,10 +244,9 @@
     }
 
     public override func isEqual(_ object: AnyObject?) -> Bool {
-        guard let otherObject = object where otherObject is NSDictionary else {
+        guard let otherDictionary = object as? NSDictionary else {
             return false
         }
-        let otherDictionary = otherObject as! NSDictionary
         return self.isEqualToDictionary(otherDictionary.bridge())
     }
 
diff --git a/Foundation/NSEnergyFormatter.swift b/Foundation/NSEnergyFormatter.swift
index 7a39faf..3142a36 100644
--- a/Foundation/NSEnergyFormatter.swift
+++ b/Foundation/NSEnergyFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSEnumerator.swift b/Foundation/NSEnumerator.swift
index b26595c..87ea320 100644
--- a/Foundation/NSEnumerator.swift
+++ b/Foundation/NSEnumerator.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSError.swift b/Foundation/NSError.swift
index 4019245..019cfce 100644
--- a/Foundation/NSError.swift
+++ b/Foundation/NSError.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSExpression.swift b/Foundation/NSExpression.swift
index 5c7f1dc..6dbb84e 100644
--- a/Foundation/NSExpression.swift
+++ b/Foundation/NSExpression.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSFileHandle.swift b/Foundation/NSFileHandle.swift
index bfaf42c..38c59ca 100644
--- a/Foundation/NSFileHandle.swift
+++ b/Foundation/NSFileHandle.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSFileManager.swift b/Foundation/NSFileManager.swift
index a97c9d5..3fbb610 100644
--- a/Foundation/NSFileManager.swift
+++ b/Foundation/NSFileManager.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -884,7 +884,7 @@
         guard let url = o as? NSURL else {
             return nil
         }
-        let path = url.path!.stringByReplacingOccurrencesOfString(baseURL.path!+"/", withString: "")
+        let path = url.path!.replacingOccurrences(of: baseURL.path!+"/", with: "")
         return NSString(string: path)
     }
 
diff --git a/Foundation/NSFormatter.swift b/Foundation/NSFormatter.swift
index c18082d..9e28395 100644
--- a/Foundation/NSFormatter.swift
+++ b/Foundation/NSFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSGeometry.swift b/Foundation/NSGeometry.swift
index 3dad19a..56623fc 100644
--- a/Foundation/NSGeometry.swift
+++ b/Foundation/NSGeometry.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -782,8 +782,8 @@
 
 private func _scanDoublesFromString(_ aString: String, number: Int) -> [Double] {
     let scanner = NSScanner(string: aString)
-    let digitSet = NSMutableCharacterSet.decimalDigitCharacterSet()
-    digitSet.addCharactersInString("-")
+    let digitSet = NSMutableCharacterSet.decimalDigits()
+    digitSet.addCharacters(in: "-")
     var result = [Double](repeating: 0.0, count: number)
     var index = 0
     
diff --git a/Foundation/NSHTTPCookie.swift b/Foundation/NSHTTPCookie.swift
index ec834aa..c3fe624 100644
--- a/Foundation/NSHTTPCookie.swift
+++ b/Foundation/NSHTTPCookie.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -54,22 +54,20 @@
 /// the various cookie attributes. It has accessors to get the various
 /// attributes of a cookie.
 public class NSHTTPCookie : NSObject {
-    private struct Cookie {
-        let comment: String?
-        let commentURL: NSURL?
-        let domain: String
-        let expiresDate: NSDate?
-        let HTTPOnly: Bool
-        let secure: Bool
-        let sessionOnly: Bool
-        let name: String
-        let path: String
-        let portList: [NSNumber]?
-        let properties: [String: Any]?
-        let value: String
-        let version: Int
-    }
-    private let cookieRepresentation: Cookie
+
+    let _comment: String?
+    let _commentURL: NSURL?
+    let _domain: String
+    let _expiresDate: NSDate?
+    let _HTTPOnly: Bool
+    let _secure: Bool
+    let _sessionOnly: Bool
+    let _name: String
+    let _path: String
+    let _portList: [NSNumber]?
+    let _value: String
+    let _version: Int
+    var _properties: [String : Any]
 
     /// Initialize a NSHTTPCookie object with a dictionary of parameters
     ///
@@ -204,7 +202,7 @@
         else {
             return nil
         }
-
+        
         let canonicalDomain: String
         if let domain = properties[NSHTTPCookieDomain] as? String {
             canonicalDomain = domain
@@ -216,99 +214,100 @@
         } else {
             return nil
         }
-
-        let secure: Bool
+        
+        _path = path
+        _name = name
+        _value = value
+        _domain = canonicalDomain
+        
         if let
             secureString = properties[NSHTTPCookieSecure] as? String
             where secureString.characters.count > 0
         {
-            secure = true
+            _secure = true
         } else {
-            secure = false
+            _secure = false
         }
 
         let version: Int
         if let
-            versionString = properties[NSHTTPCookieSecure] as? String
+            versionString = properties[NSHTTPCookieVersion] as? String
             where versionString == "1"
         {
             version = 1
         } else {
             version = 0
         }
-
-        let portList: [NSNumber]?
-        if let portString = properties[NSHTTPCookiePort] as? String {
-            portList = portString.characters
+        _version = version
+        
+        if let portString = properties[NSHTTPCookiePort] as? String
+        where _version == 1 {
+            _portList = portString.characters
                 .split(separator: ",")
                 .flatMap { Int(String($0)) }
                 .map { NSNumber(integer: $0) }
         } else {
-            portList = nil
+            _portList = nil
         }
 
         // TODO: factor into a utility function
-        let expiresDate: NSDate?
         if version == 0 {
             let expiresProperty = properties[NSHTTPCookieExpires]
             if let date = expiresProperty as? NSDate {
-                // If the dictionary value is already an NSDate,
-                // nothing left to do
-                expiresDate = date
+                _expiresDate = date
             } else if let dateString = expiresProperty as? String {
-                // If the dictionary value is a string, parse it
                 let formatter = NSDateFormatter()
-                formatter.dateFormat = "yyyy-MM-dd'T'HH:mm"
-
+                formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss O"   // per RFC 6265 '<rfc1123-date, defined in [RFC2616], Section 3.3.1>'
                 let timeZone = NSTimeZone(abbreviation: "GMT")
                 formatter.timeZone = timeZone
-
-                expiresDate = formatter.dateFromString(dateString)
+                _expiresDate = formatter.dateFromString(dateString)
             } else {
-                expiresDate = nil
+                _expiresDate = nil
             }
-        } else if version == 1 {
-            if let
-                maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
-                secondsFromNow = Double(maximumAge)
-            {
-                expiresDate = NSDate(timeIntervalSinceNow: secondsFromNow)
-            } else {
-                expiresDate = nil
-            }
-        } else {
-            expiresDate = nil
-        }
-
-        var discard = false
-        if let discardString = properties[NSHTTPCookieDiscard] as? String {
-            discard = discardString == "TRUE"
         } else if let
-            _ = properties[NSHTTPCookieMaximumAge] as? String
-            where version >= 1
-        {
-            discard = false
+            maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
+            secondsFromNow = Int(maximumAge)
+            where _version == 1 {
+            _expiresDate = NSDate(timeIntervalSinceNow: Double(secondsFromNow))
+        } else {
+            _expiresDate = nil
         }
-
-        // TODO: commentURL can be a string or NSURL
-
-        self.cookieRepresentation = Cookie(
-            comment: version == 1 ?
-                properties[NSHTTPCookieComment] as? String : nil,
-            commentURL: version == 1 ?
-                properties[NSHTTPCookieCommentURL] as? NSURL : nil,
-            domain: canonicalDomain,
-            expiresDate: expiresDate,
-            HTTPOnly: secure,
-            secure: secure,
-            sessionOnly: discard,
-            name: name,
-            path: path,
-            portList: version == 1 ? portList : nil,
-            properties: properties,
-            value: value,
-            version: version
-        )
+        
+        
+        if let discardString = properties[NSHTTPCookieDiscard] as? String {
+            _sessionOnly = discardString == "TRUE"
+        } else {
+            _sessionOnly = properties[NSHTTPCookieMaximumAge] == nil && version >= 1
+        }
+        if version == 0 {
+            _comment = nil
+            _commentURL = nil
+        } else {
+            _comment = properties[NSHTTPCookieComment] as? String
+            if let commentURL = properties[NSHTTPCookieCommentURL] as? NSURL {
+                _commentURL = commentURL
+            } else if let commentURL = properties[NSHTTPCookieCommentURL] as? String {
+                _commentURL = NSURL(string: commentURL)
+            } else {
+                _commentURL = nil
+            }
+        }
+        _HTTPOnly = false
+        _properties = [NSHTTPCookieComment : properties[NSHTTPCookieComment],
+                       NSHTTPCookieCommentURL : properties[NSHTTPCookieCommentURL],
+                       "Created" : NSDate().timeIntervalSinceReferenceDate,         // Cocoa Compatibility
+                       NSHTTPCookieDiscard : _sessionOnly,
+                       NSHTTPCookieDomain : _domain,
+                       NSHTTPCookieExpires : _expiresDate,
+                       NSHTTPCookieMaximumAge : properties[NSHTTPCookieMaximumAge],
+                       NSHTTPCookieName : _name,
+                       NSHTTPCookieOriginURL : properties[NSHTTPCookieOriginURL],
+                       NSHTTPCookiePath : _path,
+                       NSHTTPCookiePort : _portList,
+                       NSHTTPCookieSecure : _secure,
+                       NSHTTPCookieValue : _value,
+                       NSHTTPCookieVersion : _version
+        ]
     }
     
     /// Return a dictionary of header fields that can be used to add the
@@ -317,14 +316,14 @@
     /// - Parameter cookies: The cookies to turn into request headers.
     /// - Returns: A dictionary where the keys are header field names, and the values
     /// are the corresponding header field values.
-    public class func requestHeaderFieldsWithCookies(_ cookies: [NSHTTPCookie]) -> [String : String] {
+    public class func requestHeaderFields(with cookies: [NSHTTPCookie]) -> [String : String] {
         var cookieString = cookies.reduce("") { (sum, next) -> String in
-            return sum + "\(next.cookieRepresentation.name)=\(next.cookieRepresentation.value); "
+            return sum + "\(next._name)=\(next._value); "
         }
         //Remove the final trailing semicolon and whitespace
         if ( cookieString.length > 0 ) {
-            cookieString.remove(at: cookieString.endIndex.predecessor())
-            cookieString.remove(at: cookieString.endIndex.predecessor())
+            cookieString.characters.removeLast()
+            cookieString.characters.removeLast()
         }
         return ["Cookie": cookieString]
     }
@@ -336,7 +335,7 @@
     /// - Parameter headerFields: The response header fields to check for cookies.
     /// - Parameter URL: The URL that the cookies came from - relevant to how the cookies are interpeted.
     /// - Returns: An array of NSHTTPCookie objects
-    public class func cookiesWithResponseHeaderFields(_ headerFields: [String : String], forURL URL: NSURL) -> [NSHTTPCookie] { NSUnimplemented() }
+    public class func cookies(withResponseHeaderFields headerFields: [String : String], forURL URL: NSURL) -> [NSHTTPCookie] { NSUnimplemented() }
     
     /// Returns a dictionary representation of the receiver.
     ///
@@ -351,7 +350,7 @@
     /// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
     /// - Note: Since this API is under consideration it may be either removed or revised in the near future
     public var properties: [String : Any]? {
-        return self.cookieRepresentation.properties
+        return _properties
     }
     
     /// The version of the receiver.
@@ -359,17 +358,17 @@
     /// Version 0 maps to "old-style" Netscape cookies.
     /// Version 1 maps to RFC2965 cookies. There may be future versions.
     public var version: Int {
-        return self.cookieRepresentation.version
+        return _version
     }
     
     /// The name of the receiver.
     public var name: String {
-        return self.cookieRepresentation.name
+        return _name
     }
     
     /// The value of the receiver.
     public var value: String {
-        return self.cookieRepresentation.value
+        return _value
     }
     
     /// Returns The expires date of the receiver.
@@ -378,16 +377,16 @@
     /// deleted. The result will be nil if there is no specific expires
     /// date. This will be the case only for *session-only* cookies.
     /*@NSCopying*/ public var expiresDate: NSDate? {
-        return self.cookieRepresentation.expiresDate
+        return _expiresDate
     }
-    
+   
     /// Whether the receiver is session-only.
     ///
     /// `true` if this receiver should be discarded at the end of the
     /// session (regardless of expiration date), `false` if receiver need not
     /// be discarded at the end of the session.
-    public var sessionOnly: Bool {
-        return self.cookieRepresentation.sessionOnly
+    public var isSessionOnly: Bool {
+        return _sessionOnly
     }
     
     /// The domain of the receiver.
@@ -397,7 +396,7 @@
     /// should be sent to subdomains as well, assuming certain other
     /// restrictions are valid. See RFC 2965 for more detail.
     public var domain: String {
-        return self.cookieRepresentation.domain
+        return _domain
     }
     
     /// The path of the receiver.
@@ -406,17 +405,17 @@
     /// domain for which this cookie should be sent. The cookie will also
     /// be sent for children of that path, so `"/"` is the most general.
     public var path: String {
-        return self.cookieRepresentation.path
+        return _path
     }
-    
+   
     /// Whether the receiver should be sent only over secure channels
     ///
     /// Cookies may be marked secure by a server (or by a javascript).
     /// Cookies marked as such must only be sent via an encrypted connection to
     /// trusted servers (i.e. via SSL or TLS), and should not be delievered to any
-    /// javascript applications to prevent cross-site scripting vulnerabilities.
-    public var secure: Bool {
-        return self.cookieRepresentation.secure
+    /// javascript applications to prevent cross-site scripting vulnerabilities. 
+    public var isSecure: Bool {
+        return _secure
     }
     
     /// Whether the receiver should only be sent to HTTP servers per RFC 2965
@@ -426,8 +425,8 @@
     /// for URL's that match both the path and domain of the respective Cookies.
     /// Specifically these cookies should not be delivered to any javascript
     /// applications to prevent cross-site scripting vulnerabilities.
-    public var HTTPOnly: Bool {
-        return self.cookieRepresentation.HTTPOnly
+    public var isHTTPOnly: Bool {
+        return _HTTPOnly
     }
     
     /// The comment of the receiver.
@@ -436,7 +435,7 @@
     /// presentation to the user explaining the contents and purpose of this
     /// cookie. It may be nil.
     public var comment: String? {
-        return self.cookieRepresentation.comment
+        return _comment
     }
     
     /// The comment URL of the receiver.
@@ -445,7 +444,7 @@
     /// presentation to the user as a link for further information about
     /// this cookie. It may be nil.
     /*@NSCopying*/ public var commentURL: NSURL? {
-        return self.cookieRepresentation.commentURL
+        return _commentURL
     }
     
     /// The list ports to which the receiver should be sent.
@@ -457,6 +456,6 @@
     /// The array may be nil, in which case this cookie can be sent to any
     /// port.
     public var portList: [NSNumber]? {
-        return self.cookieRepresentation.portList
+        return _portList
     }
 }
diff --git a/Foundation/NSHTTPCookieStorage.swift b/Foundation/NSHTTPCookieStorage.swift
index fd1667e..870b6b7 100644
--- a/Foundation/NSHTTPCookieStorage.swift
+++ b/Foundation/NSHTTPCookieStorage.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSHost.swift b/Foundation/NSHost.swift
index 84edbf5..766c23b 100644
--- a/Foundation/NSHost.swift
+++ b/Foundation/NSHost.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSIndexPath.swift b/Foundation/NSIndexPath.swift
index 2a4a2b2..1ee5c8c 100644
--- a/Foundation/NSIndexPath.swift
+++ b/Foundation/NSIndexPath.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSIndexSet.swift b/Foundation/NSIndexSet.swift
index 6602bdc..feb43b3 100644
--- a/Foundation/NSIndexSet.swift
+++ b/Foundation/NSIndexSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSJSONSerialization.swift b/Foundation/NSJSONSerialization.swift
index d3422dc..eaa530e 100644
--- a/Foundation/NSJSONSerialization.swift
+++ b/Foundation/NSJSONSerialization.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -96,7 +96,7 @@
     
     /* Generate JSON data from a Foundation object. If the object will not produce valid JSON then an exception will be thrown. Setting the NSJSONWritingPrettyPrinted option will generate JSON with whitespace designed to make the output more readable. If that option is not set, the most compact possible JSON will be generated. If an error occurs, the error parameter will be set and the return value will be nil. The resulting data is a encoded in UTF-8.
      */
-    public class func dataWithJSONObject(_ obj: AnyObject, options opt: NSJSONWritingOptions) throws -> NSData {
+    public class func data(withJSONObject obj: AnyObject, options opt: NSJSONWritingOptions = []) throws -> NSData {
         guard obj is NSArray || obj is NSDictionary else {
             throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.PropertyListReadCorruptError.rawValue, userInfo: [
                 "NSDebugDescription" : "Top-level object was not NSArray or NSDictionary"
@@ -109,7 +109,7 @@
             pretty: opt.contains(.PrettyPrinted),
             writer: { (str: String?) in
                 if let str = str {
-                    result.append(str.bridge().cStringUsingEncoding(NSUTF8StringEncoding)!, length: str.lengthOfBytesUsingEncoding(NSUTF8StringEncoding))
+                    result.append(str.bridge().cString(using: NSUTF8StringEncoding)!, length: str.lengthOfBytes(using: NSUTF8StringEncoding))
                 }
             }
         )
@@ -123,7 +123,7 @@
        The data must be in one of the 5 supported encodings listed in the JSON specification: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. The data may or may not have a BOM. The most efficient encoding to use for parsing is UTF-8, so if you have a choice in encoding the data passed to this method, use UTF-8.
      */
     /// - Experiment: Note that the return type of this function is different than on Darwin Foundation (Any instead of AnyObject). This is likely to change once we have a more complete story for bridging in place.
-    public class func JSONObjectWithData(_ data: NSData, options opt: NSJSONReadingOptions) throws -> Any {
+    public class func jsonObject(with data: NSData, options opt: NSJSONReadingOptions = []) throws -> Any {
         
         let bytes = UnsafePointer<UInt8>(data.bytes)
         let encoding: NSStringEncoding
@@ -161,7 +161,7 @@
     
     /* Create a JSON object from JSON data stream. The stream should be opened and configured. All other behavior of this method is the same as the JSONObjectWithData:options:error: method.
      */
-    public class func JSONObjectWithStream(_ stream: NSInputStream, options opt: NSJSONReadingOptions) throws -> AnyObject {
+    public class func jsonObject(with stream: NSInputStream, options opt: NSJSONReadingOptions = []) throws -> AnyObject {
         NSUnimplemented()
     }
 }
@@ -406,6 +406,7 @@
     }
 
     typealias Index = Int
+    typealias IndexDistance = Int
 
     struct UnicodeSource {
         let buffer: UnsafeBufferPointer<UInt8>
@@ -467,7 +468,7 @@
             return input + step <= buffer.endIndex
         }
         
-        func distanceFromStart(_ index: Index) -> Index.Distance {
+        func distanceFromStart(_ index: Index) -> IndexDistance {
             return buffer.startIndex.distance(to: index) / step
         }
     }
@@ -524,7 +525,7 @@
     //MARK: - String Parsing
 
     func parseString(_ input: Index) throws -> (String, Index)? {
-        guard let beginIndex = try consumeStructure(Structure.QuotationMark, input: input) else {
+        guard let beginIndex = try consumeWhitespace(input).flatMap(consumeASCII(Structure.QuotationMark)) else {
             return nil
         }
         var chunkIndex: Int = beginIndex
@@ -624,24 +625,34 @@
         0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, // 0...9
         0x2E, 0x2D, 0x2B, 0x45, 0x65, // . - + E e
     ]
-    func parseNumber(_ input: Index) throws -> (Double, Index)? {
-        func parseDouble(_ address: UnsafePointer<UInt8>) -> (Double, Index.Distance)? {
+    func parseNumber(_ input: Index) throws -> (Any, Index)? {
+        func parseTypedNumber(_ address: UnsafePointer<UInt8>) -> (Any, IndexDistance)? {
             let startPointer = UnsafePointer<Int8>(address)
-            let endPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1)
-            defer { endPointer.deallocateCapacity(1) }
+            let intEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1)
+            defer { intEndPointer.deallocateCapacity(1) }
+            let doubleEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1)
+            defer { doubleEndPointer.deallocateCapacity(1) }
             
-            let result = strtod(startPointer, endPointer)
-            let distance = startPointer.distance(to: endPointer[0]!)
+            let intResult = strtol(startPointer, intEndPointer, 10)
+            let intDistance = startPointer.distance(to: intEndPointer[0]!)
+            let doubleResult = strtod(startPointer, doubleEndPointer)
+            let doubleDistance = startPointer.distance(to: doubleEndPointer[0]!)
             
-            guard distance > 0 else {
+            guard intDistance > 0 || doubleDistance > 0 else {
                 return nil
             }
             
-            return (result, distance)
+            if intDistance == doubleDistance {
+                return (intResult, intDistance)
+            }
+            guard doubleDistance > 0 else {
+                return nil
+            }
+            return (doubleResult, doubleDistance)
         }
         
         if source.encoding == NSUTF8StringEncoding {
-            return parseDouble(source.buffer.baseAddress!.advanced(by: input)).map { return ($0.0, input + $0.1) }
+            return parseTypedNumber(source.buffer.baseAddress!.advanced(by: input)).map { return ($0.0, input + $0.1) }
         }
         else {
             var numberCharacters = [UInt8]()
@@ -653,7 +664,7 @@
             
             numberCharacters.append(0)
             
-            return numberCharacters.withUnsafeBufferPointer { parseDouble($0.baseAddress!) }.map { return ($0.0, index) }
+            return numberCharacters.withUnsafeBufferPointer { parseTypedNumber($0.baseAddress!) }.map { return ($0.0, index) }
         }
     }
 
diff --git a/Foundation/NSKeyedArchiver.swift b/Foundation/NSKeyedArchiver.swift
index afb3883..6be717e 100644
--- a/Foundation/NSKeyedArchiver.swift
+++ b/Foundation/NSKeyedArchiver.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSKeyedCoderOldStyleArray.swift b/Foundation/NSKeyedCoderOldStyleArray.swift
index c800f91..afb2a04 100644
--- a/Foundation/NSKeyedCoderOldStyleArray.swift
+++ b/Foundation/NSKeyedCoderOldStyleArray.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSKeyedUnarchiver.swift b/Foundation/NSKeyedUnarchiver.swift
index 351bfca..bd0fc37 100644
--- a/Foundation/NSKeyedUnarchiver.swift
+++ b/Foundation/NSKeyedUnarchiver.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -527,7 +527,7 @@
         Helper for NSArray/NSDictionary to dereference and decode an array of objects
      */
     internal func _decodeArrayOfObjectsForKey(_ key: String,
-                                              @noescape withBlock block: (Any) -> Void) throws {
+                                              withBlock block: @noescape (Any) -> Void) throws {
         let objectRefs : Array<Any>? = _decodeValue(forKey: key)
         
         guard let unwrappedObjectRefs = objectRefs else {
@@ -828,7 +828,7 @@
             break
         case .CharPtr:
             if let ns = decodeObject() as? NSString {
-                let string = ns.UTF8String! // XXX leaky
+                let string = ns.utf8String! // XXX leaky
                 unsafeBitCast(addr, to: UnsafeMutablePointer<UnsafePointer<Int8>>.self).pointee = string
             }
             break
diff --git a/Foundation/NSLengthFormatter.swift b/Foundation/NSLengthFormatter.swift
index d566a5b..515cead 100644
--- a/Foundation/NSLengthFormatter.swift
+++ b/Foundation/NSLengthFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSLocale.swift b/Foundation/NSLocale.swift
index b8c7d9b..3d7122a 100644
--- a/Foundation/NSLocale.swift
+++ b/Foundation/NSLocale.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSLock.swift b/Foundation/NSLock.swift
index 2250028..5df4681 100644
--- a/Foundation/NSLock.swift
+++ b/Foundation/NSLock.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -51,7 +51,7 @@
 }
 
 extension NSLock {
-    internal func synchronized<T>(@noescape _ closure: () -> T) -> T {
+    internal func synchronized<T>(_ closure: @noescape () -> T) -> T {
         self.lock()
         defer { self.unlock() }
         return closure()
diff --git a/Foundation/NSLog.swift b/Foundation/NSLog.swift
index 08cc361..232d19d 100644
--- a/Foundation/NSLog.swift
+++ b/Foundation/NSLog.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSMassFormatter.swift b/Foundation/NSMassFormatter.swift
index 6c0e687..1a8c6af 100644
--- a/Foundation/NSMassFormatter.swift
+++ b/Foundation/NSMassFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSNotification.swift b/Foundation/NSNotification.swift
index c48cc2b..bb6fcfb 100755
--- a/Foundation/NSNotification.swift
+++ b/Foundation/NSNotification.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSNotificationQueue.swift b/Foundation/NSNotificationQueue.swift
index a250989..660bb5d 100644
--- a/Foundation/NSNotificationQueue.swift
+++ b/Foundation/NSNotificationQueue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSNull.swift b/Foundation/NSNull.swift
index f061537..3300e53 100644
--- a/Foundation/NSNull.swift
+++ b/Foundation/NSNull.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSNumber.swift b/Foundation/NSNumber.swift
index 2b2b63e..2131765 100644
--- a/Foundation/NSNumber.swift
+++ b/Foundation/NSNumber.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -458,8 +458,15 @@
     }
 
     public func descriptionWithLocale(_ locale: AnyObject?) -> String {
-        guard let aLocale = locale else { return description }
-        let formatter = CFNumberFormatterCreate(nil, (aLocale as! NSLocale)._cfObject, kCFNumberFormatterDecimalStyle)
+        let aLocale = locale
+        let formatter: CFNumberFormatter
+        if (aLocale == nil) {
+            formatter = CFNumberFormatterCreate(nil, CFLocaleCopyCurrent(), kCFNumberFormatterNoStyle)
+            CFNumberFormatterSetProperty(formatter, kCFNumberFormatterMaxFractionDigits, 15._bridgeToObject())
+
+        } else {
+            formatter = CFNumberFormatterCreate(nil, (aLocale as! NSLocale)._cfObject, kCFNumberFormatterDecimalStyle)
+        }
         return CFNumberFormatterCreateStringWithNumber(nil, formatter, self._cfObject)._swiftObject
     }
     
@@ -468,10 +475,7 @@
     }
     
     public override var description: String {
-        let locale = CFLocaleCopyCurrent()
-        let formatter = CFNumberFormatterCreate(nil, locale, kCFNumberFormatterDecimalStyle)
-        CFNumberFormatterSetProperty(formatter, kCFNumberFormatterMaxFractionDigits, 15._bridgeToObject())
-        return CFNumberFormatterCreateStringWithNumber(nil, formatter, self._cfObject)._swiftObject
+        return descriptionWithLocale(nil)
     }
 }
 
diff --git a/Foundation/NSNumberFormatter.swift b/Foundation/NSNumberFormatter.swift
index a7658d7..d5b304b 100644
--- a/Foundation/NSNumberFormatter.swift
+++ b/Foundation/NSNumberFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSObjCRuntime.swift b/Foundation/NSObjCRuntime.swift
index 8bf47bc..e3660a3 100644
--- a/Foundation/NSObjCRuntime.swift
+++ b/Foundation/NSObjCRuntime.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -249,7 +249,7 @@
  */
 public func NSStringFromClass(_ aClass: AnyClass) -> String {
     let aClassName = String(reflecting: aClass).bridge()
-    let components = aClassName.componentsSeparatedByString(".")
+    let components = aClassName.components(separatedBy: ".")
     
     guard components.count == 2 else {
         fatalError("NSStringFromClass: \(String(reflecting: aClass)) is not a top-level class")
@@ -272,7 +272,7 @@
  */
 public func NSClassFromString(_ aClassName: String) -> AnyClass? {
     let aClassNameWithPrefix : String
-    let components = aClassName.bridge().componentsSeparatedByString(".")
+    let components = aClassName.bridge().components(separatedBy: ".")
     
     switch components.count {
     case 1:
diff --git a/Foundation/NSObject.swift b/Foundation/NSObject.swift
index 5d502e6..4f47f1b 100644
--- a/Foundation/NSObject.swift
+++ b/Foundation/NSObject.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSOperation.swift b/Foundation/NSOperation.swift
index 258dd7c..b88efbe 100644
--- a/Foundation/NSOperation.swift
+++ b/Foundation/NSOperation.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -204,6 +204,7 @@
     var all = [NSOperation]()
     
     mutating func insert(_ operation: NSOperation) {
+        all.append(operation)
         switch operation.queuePriority {
         case .VeryLow:
             veryLow.append(operation)
@@ -257,29 +258,31 @@
     }
     
     mutating func dequeue() -> NSOperation? {
+        var result : NSOperation?
         if veryHigh.count > 0 {
-            return veryHigh.remove(at: 0)
+            result = veryHigh.remove(at: 0)
+        } else if high.count > 0 {
+            result = high.remove(at: 0)
+        } else if normal.count > 0 {
+            result = normal.remove(at: 0)
+        } else if low.count > 0 {
+            result = low.remove(at: 0)
+        } else if veryLow.count > 0 {
+            result = veryLow.remove(at: 0)
         }
-        if high.count > 0 {
-            return high.remove(at: 0)
+
+        if let idx = all.index(of: result!) {
+            all.remove(at: idx)
         }
-        if normal.count > 0 {
-            return normal.remove(at: 0)
-        }
-        if low.count > 0 {
-            return low.remove(at: 0)
-        }
-        if veryLow.count > 0 {
-            return veryLow.remove(at: 0)
-        }
-        return nil
+
+        return result
     }
     
     var count: Int {
         return all.count
     }
     
-    func map<T>(@noescape _ transform: (NSOperation) throws -> T) rethrows -> [T] {
+    func map<T>(_ transform: @noescape (NSOperation) throws -> T) rethrows -> [T] {
         return try all.map(transform)
     }
 }
diff --git a/Foundation/NSOrderedSet.swift b/Foundation/NSOrderedSet.swift
index d87bcff..0d4a29e 100644
--- a/Foundation/NSOrderedSet.swift
+++ b/Foundation/NSOrderedSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPathUtilities.swift b/Foundation/NSPathUtilities.swift
index e197e1a..5f6b7bb 100644
--- a/Foundation/NSPathUtilities.swift
+++ b/Foundation/NSPathUtilities.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -45,7 +45,7 @@
         
         // Find the beginning of the component
         while curPos > startPos {
-            let prevPos = curPos.predecessor()
+            let prevPos = characterView.index(before: curPos)
             if characterView[prevPos] == "/" {
                 break
             }
@@ -66,7 +66,7 @@
         
         // Find the beginning of the extension
         while curPos > lastCompStartPos {
-            let prevPos = curPos.predecessor()
+            let prevPos = characterView.index(before: curPos)
             let char = characterView[prevPos]
             if char == "/" {
                 return nil
@@ -111,21 +111,21 @@
                     if characterView[curPos] == "/" {
                         var afterLastSlashPos = curPos
                         while afterLastSlashPos < endPos && characterView[afterLastSlashPos] == "/" {
-                            afterLastSlashPos = afterLastSlashPos.successor()
+                            afterLastSlashPos = characterView.index(after: afterLastSlashPos)
                         }
-                        if afterLastSlashPos != curPos.successor() {
+                        if afterLastSlashPos != characterView.index(after: curPos) {
                             characterView.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
                             endPos = characterView.endIndex
                         }
                         curPos = afterLastSlashPos
                     } else {
-                        curPos = curPos.successor()
+                        curPos = characterView.index(after: curPos)
                     }
                 }
             }
         }
         if stripTrailing && result.length > 1 && result.hasSuffix("/") {
-            result.remove(at: result.characters.endIndex.predecessor())
+            result.remove(at: result.characters.index(before: result.characters.endIndex))
         }
         return result
     }
@@ -185,14 +185,14 @@
             
             while curPos < endPos {
                 while curPos < endPos && characterView[curPos] == "/" {
-                    curPos = curPos.successor()
+                    curPos = characterView.index(after: curPos)
                 }
                 if curPos == endPos {
                     break
                 }
                 var curEnd = curPos
                 while curEnd < endPos && characterView[curEnd] != "/" {
-                    curEnd = curEnd.successor()
+                    curEnd = characterView.index(after: curEnd)
                 }
                 result.append(String(characterView[curPos ..< curEnd]))
                 curPos = curEnd
@@ -226,12 +226,12 @@
             return ""
         
         // absolute path, single component
-        case fixedSelf.startIndex.successor():
+        case fixedSelf.index(after: fixedSelf.startIndex):
             return "/"
         
         // all common cases
         case let startOfLast:
-            return String(fixedSelf.characters.prefix(upTo: startOfLast.predecessor()))
+            return String(fixedSelf.characters.prefix(upTo: fixedSelf.index(before: startOfLast)))
         }
     }
     
@@ -251,21 +251,21 @@
                     if characterView[curPos] == "/" {
                         var afterLastSlashPos = curPos
                         while afterLastSlashPos < endPos && characterView[afterLastSlashPos] == "/" {
-                            afterLastSlashPos = afterLastSlashPos.successor()
+                            afterLastSlashPos = characterView.index(after: afterLastSlashPos)
                         }
-                        if afterLastSlashPos != curPos.successor() {
+                        if afterLastSlashPos != characterView.index(after: curPos) {
                             characterView.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
                             endPos = characterView.endIndex
                         }
                         curPos = afterLastSlashPos
                     } else {
-                        curPos = curPos.successor()
+                        curPos = characterView.index(after: curPos)
                     }
                 }
             }
         }
         if stripTrailing && result.hasSuffix("/") {
-            result.remove(at: result.characters.endIndex.predecessor())
+            result.remove(at: result.characters.index(before: result.characters.endIndex))
         }
         return result
     }
@@ -306,7 +306,7 @@
             return fixedSelf
         }
         if let extensionPos = (fixedSelf._startOfPathExtension) {
-            return String(fixedSelf.characters.prefix(upTo: extensionPos.predecessor()))
+            return String(fixedSelf.characters.prefix(upTo: fixedSelf.characters.index(before: extensionPos)))
         } else {
             return fixedSelf
         }
@@ -327,7 +327,8 @@
         }
 
         let endOfUserName = _swiftObject.characters.index(of: "/") ?? _swiftObject.endIndex
-        let userName = String(_swiftObject.characters[_swiftObject.startIndex.successor()..<endOfUserName])
+        let startOfUserName = _swiftObject.characters.index(after: _swiftObject.characters.startIndex)
+        let userName = String(_swiftObject.characters[startOfUserName..<endOfUserName])
         let optUserName: String? = userName.isEmpty ? nil : userName
         
         guard let homeDir = NSHomeDirectoryForUser(optUserName) else {
@@ -497,7 +498,7 @@
         if caseSensetive {
             return { $0 != nil && $0!.hasPrefix(thePrefix) }
         } else {
-            return { $0 != nil && $0!.bridge().rangeOfString(thePrefix, options: .CaseInsensitiveSearch).location == 0 }
+            return { $0 != nil && $0!.bridge().range(of: thePrefix, options: .caseInsensitiveSearch).location == 0 }
         }
     }
     
diff --git a/Foundation/NSPersonNameComponents.swift b/Foundation/NSPersonNameComponents.swift
index 5acc4a5..c56f5d7 100644
--- a/Foundation/NSPersonNameComponents.swift
+++ b/Foundation/NSPersonNameComponents.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPersonNameComponentsFormatter.swift b/Foundation/NSPersonNameComponentsFormatter.swift
index 96ce01b..48460b5 100644
--- a/Foundation/NSPersonNameComponentsFormatter.swift
+++ b/Foundation/NSPersonNameComponentsFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPort.swift b/Foundation/NSPort.swift
index 91a565c..935042a 100644
--- a/Foundation/NSPort.swift
+++ b/Foundation/NSPort.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPortMessage.swift b/Foundation/NSPortMessage.swift
index 8f946ad..89ead16 100644
--- a/Foundation/NSPortMessage.swift
+++ b/Foundation/NSPortMessage.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPredicate.swift b/Foundation/NSPredicate.swift
index b01f2cc..d136b65 100644
--- a/Foundation/NSPredicate.swift
+++ b/Foundation/NSPredicate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -89,25 +89,51 @@
 }
 
 extension NSMutableArray {
-    public func filterUsingPredicate(_ predicate: NSPredicate) { NSUnimplemented() } // evaluate a predicate against an array of objects and filter the mutable array directly
+    public func filterUsingPredicate(_ predicate: NSPredicate) {
+        let indexesToRemove = NSMutableIndexSet()
+        for (index, object) in self.enumerated() {
+            if !predicate.evaluateWithObject(object) {
+                indexesToRemove.addIndex(index)
+            }
+        }
+        self.removeObjectsAtIndexes(indexesToRemove)
+    } // evaluate a predicate against an array of objects and filter the mutable array directly
 }
 
 extension NSSet {
-    public func filteredSetUsingPredicate(_ predicate: NSPredicate) -> Set<NSObject> { NSUnimplemented() } // evaluate a predicate against a set of objects and return a filtered set
+    public func filteredSetUsingPredicate(_ predicate: NSPredicate) -> Set<NSObject> {
+        return Set(bridge().filter({ object in
+            return predicate.evaluateWithObject(object)
+        }))
+    } // evaluate a predicate against a set of objects and return a filtered set
 }
 
 extension NSMutableSet {
-    public func filterUsingPredicate(_ predicate: NSPredicate) { NSUnimplemented() } // evaluate a predicate against a set of objects and filter the mutable set directly
+    public func filterUsingPredicate(_ predicate: NSPredicate) {
+        for object in self {
+            if !predicate.evaluateWithObject(object) {
+                self.removeObject(object)
+            }
+        }
+    } // evaluate a predicate against a set of objects and filter the mutable set directly
 }
 
 extension NSOrderedSet {
-    
-    public func filteredOrderedSetUsingPredicate(_ p: NSPredicate) -> NSOrderedSet { NSUnimplemented() } // evaluate a predicate against an ordered set of objects and return a filtered ordered set
+    public func filteredOrderedSetUsingPredicate(_ predicate: NSPredicate) -> NSOrderedSet {
+        return NSOrderedSet(array: self._orderedStorage.bridge().filter({ object in
+            return predicate.evaluateWithObject(object)
+        }))
+    } // evaluate a predicate against an ordered set of objects and return a filtered ordered set
 }
 
 extension NSMutableOrderedSet {
-    
-    public func filterUsingPredicate(_ p: NSPredicate) { NSUnimplemented() } // evaluate a predicate against an ordered set of objects and filter the mutable ordered set directly
+    public func filterUsingPredicate(_ predicate: NSPredicate) {
+        let indexesToRemove = NSMutableIndexSet()
+        for (index, object) in self.enumerated() {
+            if !predicate.evaluateWithObject(object) {
+                indexesToRemove.addIndex(index)
+            }
+        }
+        self.removeObjectsAtIndexes(indexesToRemove)
+    } // evaluate a predicate against an ordered set of objects and filter the mutable ordered set directly
 }
-
-
diff --git a/Foundation/NSProcessInfo.swift b/Foundation/NSProcessInfo.swift
index 87b0b02..5d910e3 100644
--- a/Foundation/NSProcessInfo.swift
+++ b/Foundation/NSProcessInfo.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSProgress.swift b/Foundation/NSProgress.swift
index 5b4baa8..edad812 100644
--- a/Foundation/NSProgress.swift
+++ b/Foundation/NSProgress.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSPropertyList.swift b/Foundation/NSPropertyList.swift
index 9f61e23..b3ad61e 100644
--- a/Foundation/NSPropertyList.swift
+++ b/Foundation/NSPropertyList.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSRange.swift b/Foundation/NSRange.swift
index 1a39337..16f32a7 100644
--- a/Foundation/NSRange.swift
+++ b/Foundation/NSRange.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -38,13 +38,13 @@
 public typealias NSRange = _NSRange
 
 extension NSRange {
-    public init(_ x: Range<Int>) {
+    public init(_ x: CountableRange<Int>) {
         location = x.startIndex
         length = x.count
     }
     
     @warn_unused_result
-    public func toRange() -> Range<Int>? {
+    public func toRange() -> CountableRange<Int>? {
         if location == NSNotFound { return nil }
         let min = location
         let max = location + length
@@ -181,7 +181,7 @@
         return emptyRange
     }
     let scanner = NSScanner(string: aString)
-    let digitSet = NSCharacterSet.decimalDigitCharacterSet()
+    let digitSet = NSCharacterSet.decimalDigits()
     scanner.scanUpToCharactersFromSet(digitSet)
     if scanner.atEnd {
         // fail early if there are no decimal digits
diff --git a/Foundation/NSRegularExpression.swift b/Foundation/NSRegularExpression.swift
index dca8f1b..d19958a 100644
--- a/Foundation/NSRegularExpression.swift
+++ b/Foundation/NSRegularExpression.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -140,7 +140,7 @@
 
 extension NSRegularExpression {
     
-    /* The fundamental matching method on NSRegularExpression is a block iterator.  There are several additional convenience methods, for returning all matches at once, the number of matches, the first match, or the range of the first match.  Each match is specified by an instance of NSTextCheckingResult (of type NSTextCheckingTypeRegularExpression) in which the overall match range is given by the range property (equivalent to rangeAtIndex:0) and any capture group ranges are given by rangeAtIndex: for indexes from 1 to numberOfCaptureGroups.  {NSNotFound, 0} is used if a particular capture group does not participate in the match.
+    /* The fundamental matching method on NSRegularExpression is a block iterator.  There are several additional convenience methods, for returning all matches at once, the number of matches, the first match, or the range of the first match.  Each match is specified by an instance of NSTextCheckingResult (of type NSTextCheckingTypeRegularExpression) in which the overall match range is given by the range property (equivalent to range at:0) and any capture group ranges are given by range at: for indexes from 1 to numberOfCaptureGroups.  {NSNotFound, 0} is used if a particular capture group does not participate in the match.
     */
     
     public func enumerateMatches(in string: String, options: NSMatchingOptions, range: NSRange, using block: (NSTextCheckingResult?, NSMatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
@@ -157,7 +157,7 @@
     
     public func matches(in string: String, options: NSMatchingOptions, range: NSRange) -> [NSTextCheckingResult] {
         var matches = [NSTextCheckingResult]()
-        enumerateMatches(in: string, options: options.subtract(.reportProgress).subtract(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
+        enumerateMatches(in: string, options: options.subtracting(.reportProgress).subtracting(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
             if let match = result {
                 matches.append(match)
             }
@@ -168,7 +168,7 @@
     
     public func numberOfMatches(in string: String, options: NSMatchingOptions, range: NSRange) -> Int {
         var count = 0
-        enumerateMatches(in: string, options: options.subtract(.reportProgress).subtract(.reportCompletion).union(.OmitResult), range: range) {_,_,_ in 
+        enumerateMatches(in: string, options: options.subtracting(.reportProgress).subtracting(.reportCompletion).union(.OmitResult), range: range) {_,_,_ in 
             count += 1
         }
         return count
@@ -176,7 +176,7 @@
     
     public func firstMatch(in string: String, options: NSMatchingOptions, range: NSRange) -> NSTextCheckingResult? {
         var first: NSTextCheckingResult?
-        enumerateMatches(in: string, options: options.subtract(.reportProgress).subtract(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
+        enumerateMatches(in: string, options: options.subtracting(.reportProgress).subtracting(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
             first = result
             stop.pointee = true
         }
@@ -185,7 +185,7 @@
     
     public func rangeOfFirstMatch(in string: String, options: NSMatchingOptions, range: NSRange) -> NSRange {
         var firstRange = NSMakeRange(NSNotFound, 0)
-        enumerateMatches(in: string, options: options.subtract(.reportProgress).subtract(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
+        enumerateMatches(in: string, options: options.subtracting(.reportProgress).subtracting(.reportCompletion), range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
             if let match = result {
                 firstRange = match.range
             } else {
@@ -214,7 +214,7 @@
         var str: String = ""
         let length = string.length
         var previousRange = NSMakeRange(0, 0)
-        let results = matches(in: string, options: options.subtract(.reportProgress).subtract(.reportCompletion), range: range)
+        let results = matches(in: string, options: options.subtracting(.reportProgress).subtracting(.reportCompletion), range: range)
         let start = string.utf16.startIndex
         
         for result in results {
@@ -239,7 +239,7 @@
     }
     
     public func replaceMatches(in string: NSMutableString, options: NSMatchingOptions, range: NSRange, withTemplate templ: String) -> Int {
-        let results = matches(in: string._swiftObject, options: options.subtract(.reportProgress).subtract(.reportCompletion), range: range)
+        let results = matches(in: string._swiftObject, options: options.subtracting(.reportProgress).subtracting(.reportCompletion), range: range)
         var count = 0
         var offset = 0
         for result in results {
@@ -247,7 +247,7 @@
             let replacement = replacementString(for: result, in: string._swiftObject, offset: offset, template: templ)
             currentRnage.location += offset
             
-            string.replaceCharactersInRange(currentRnage, withString: replacement)
+            string.replaceCharacters(in: currentRnage, with: replacement)
             offset += replacement.length - currentRnage.length
             count += 1
         }
@@ -259,10 +259,10 @@
     public func replacementString(for result: NSTextCheckingResult, in string: String, offset: Int, template templ: String) -> String {
         // ??? need to consider what happens if offset takes range out of bounds due to replacement
         struct once {
-            static let characterSet = NSCharacterSet(charactersInString: "\\$")
+            static let characterSet = NSCharacterSet(charactersIn: "\\$")
         }
         let template = templ._nsObject
-        var range = template.rangeOfCharacterFromSet(once.characterSet)
+        var range = template.rangeOfCharacter(from: once.characterSet)
         if range.length > 0 {
             var numberOfDigits = 1
             var orderOfMagnitude = 10
@@ -274,16 +274,16 @@
                 orderOfMagnitude *= 10
             }
             while range.length > 0 {
-                var c = str.characterAtIndex(range.location)
+                var c = str.character(at: range.location)
                 if c == unichar(unicodeScalarLiteral: "\\") {
-                    str.deleteCharactersInRange(range)
+                    str.deleteCharacters(in: range)
                     length -= range.length
                     range.length = 1
                 } else if c == unichar(unicodeScalarLiteral: "$") {
                     var groupNumber: Int = NSNotFound
                     var idx = NSMaxRange(range)
                     while idx < length && idx < NSMaxRange(range) + numberOfDigits {
-                        c = str.characterAtIndex(idx)
+                        c = str.character(at: idx)
                         if c < unichar(unicodeScalarLiteral: "0") || c > unichar(unicodeScalarLiteral: "9") {
                             break
                         }
@@ -300,7 +300,7 @@
                         var substringRange = NSMakeRange(NSNotFound, 0)
                         var substring = ""
                         if groupNumber < numberOfRanges {
-                            substringRange = result.rangeAtIndex(groupNumber)
+                            substringRange = result.range(at: groupNumber)
                         }
                         if substringRange.location != NSNotFound {
                             substringRange.location += offset
@@ -311,7 +311,7 @@
                             let max = start.advanced(by: substringRange.location + substringRange.length)
                             substring = String(string.utf16[min..<max])
                         }
-                        str.replaceCharactersInRange(rangeToReplace, withString: substring)
+                        str.replaceCharacters(in: rangeToReplace, with: substring)
                         
                         length += substringRange.length - rangeToReplace.length
                         range.length = substringRange.length
@@ -320,7 +320,7 @@
                 if NSMaxRange(range) > length {
                     break
                 }
-                range = str.rangeOfCharacterFromSet(once.characterSet, options: [], range: NSMakeRange(NSMaxRange(range), length - NSMaxRange(range)))
+                range = str.rangeOfCharacter(from: once.characterSet, options: [], range: NSMakeRange(NSMaxRange(range), length - NSMaxRange(range)))
             }
             return str._swiftObject
         }
diff --git a/Foundation/NSRunLoop.swift b/Foundation/NSRunLoop.swift
index d20da98..88a96c1 100644
--- a/Foundation/NSRunLoop.swift
+++ b/Foundation/NSRunLoop.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSScanner.swift b/Foundation/NSScanner.swift
index ba0ac03..f3f4400 100644
--- a/Foundation/NSScanner.swift
+++ b/Foundation/NSScanner.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -65,7 +65,7 @@
     public var caseSensitive: Bool = false
     public var locale: NSLocale?
     
-    internal static let defaultSkipSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
+    internal static let defaultSkipSet = NSCharacterSet.whitespacesAndNewlines()
     
     public init(string: String) {
         _scanString = string
@@ -206,7 +206,7 @@
 
 private func isADigit(_ ch: unichar) -> Bool {
     struct Local {
-        static let set = NSCharacterSet.decimalDigitCharacterSet()
+        static let set = NSCharacterSet.decimalDigits()
     }
     return Local.set.characterIsMember(ch)
 }
@@ -497,7 +497,7 @@
         var stringLoc = scanLocation
         let stringLen = string.length
         if let invSet = invertedSkipSet {
-            let range = string._nsObject.rangeOfCharacterFromSet(invSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
+            let range = string._nsObject.rangeOfCharacter(from: invSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
             stringLoc = range.length > 0 ? range.location : stringLen
         }
         return stringLoc == stringLen
@@ -627,17 +627,17 @@
         let str = self.string._bridgeToObject()
         var stringLoc = scanLocation
         let stringLen = str.length
-        let options: NSStringCompareOptions = [caseSensitive ? [] : NSStringCompareOptions.CaseInsensitiveSearch, NSStringCompareOptions.AnchoredSearch]
+        let options: NSStringCompareOptions = [caseSensitive ? [] : NSStringCompareOptions.caseInsensitiveSearch, NSStringCompareOptions.anchoredSearch]
         
         if let invSkipSet = charactersToBeSkipped?.invertedSet {
-            let range = str.rangeOfCharacterFromSet(invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
+            let range = str.rangeOfCharacter(from: invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
             stringLoc = range.length > 0 ? range.location : stringLen
         }
         
-        let range = str.rangeOfString(searchString, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
+        let range = str.range(of: searchString, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
         if range.length > 0 {
             /* ??? Is the range below simply range? 99.9% of the time, and perhaps even 100% of the time... Hmm... */
-            let res = str.substringWithRange(NSMakeRange(stringLoc, range.location + range.length - stringLoc))
+            let res = str.substring(with: NSMakeRange(stringLoc, range.location + range.length - stringLoc))
             scanLocation = range.location + range.length
             return res
         }
@@ -648,17 +648,17 @@
         let str = self.string._bridgeToObject()
         var stringLoc = scanLocation
         let stringLen = str.length
-        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.CaseInsensitiveSearch
+        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.caseInsensitiveSearch
         if let invSkipSet = charactersToBeSkipped?.invertedSet {
-            let range = str.rangeOfCharacterFromSet(invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
+            let range = str.rangeOfCharacter(from: invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
             stringLoc = range.length > 0 ? range.location : stringLen
         }
-        var range = str.rangeOfCharacterFromSet(set.invertedSet, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
+        var range = str.rangeOfCharacter(from: set.invertedSet, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
         if range.length == 0 {
             range.location = stringLen
         }
         if stringLoc != range.location {
-            let res = str.substringWithRange(NSMakeRange(stringLoc, range.location - stringLoc))
+            let res = str.substring(with: NSMakeRange(stringLoc, range.location - stringLoc))
             scanLocation = range.location
             return res
         }
@@ -669,17 +669,17 @@
         let str = self.string._bridgeToObject()
         var stringLoc = scanLocation
         let stringLen = str.length
-        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.CaseInsensitiveSearch
+        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.caseInsensitiveSearch
         if let invSkipSet = charactersToBeSkipped?.invertedSet {
-            let range = str.rangeOfCharacterFromSet(invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
+            let range = str.rangeOfCharacter(from: invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
             stringLoc = range.length > 0 ? range.location : stringLen
         }
-        var range = str.rangeOfString(string, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
+        var range = str.range(of: string, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
         if range.length == 0 {
             range.location = stringLen
         }
         if stringLoc != range.location {
-            let res = str.substringWithRange(NSMakeRange(stringLoc, range.location - stringLoc))
+            let res = str.substring(with: NSMakeRange(stringLoc, range.location - stringLoc))
             scanLocation = range.location
             return res
         }
@@ -690,17 +690,17 @@
         let str = self.string._bridgeToObject()
         var stringLoc = scanLocation
         let stringLen = str.length
-        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.CaseInsensitiveSearch
+        let options: NSStringCompareOptions = caseSensitive ? [] : NSStringCompareOptions.caseInsensitiveSearch
         if let invSkipSet = charactersToBeSkipped?.invertedSet {
-            let range = str.rangeOfCharacterFromSet(invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
+            let range = str.rangeOfCharacter(from: invSkipSet, options: [], range: NSMakeRange(stringLoc, stringLen - stringLoc))
             stringLoc = range.length > 0 ? range.location : stringLen
         }
-        var range = str.rangeOfCharacterFromSet(set, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
+        var range = str.rangeOfCharacter(from: set, options: options, range: NSMakeRange(stringLoc, stringLen - stringLoc))
         if range.length == 0 {
             range.location = stringLen
         }
         if stringLoc != range.location {
-            let res = str.substringWithRange(NSMakeRange(stringLoc, range.location - stringLoc))
+            let res = str.substring(with: NSMakeRange(stringLoc, range.location - stringLoc))
             scanLocation = range.location
             return res
         }
diff --git a/Foundation/NSSet.swift b/Foundation/NSSet.swift
index e20feb2..d148dde 100644
--- a/Foundation/NSSet.swift
+++ b/Foundation/NSSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -271,7 +271,7 @@
     public func setByAddingObjectsFromSet(_ other: Set<NSObject>) -> Set<NSObject> {
         var result = Set<NSObject>(minimumCapacity: Swift.max(count, other.count))
         if self.dynamicType === NSSet.self || self.dynamicType === NSMutableSet.self {
-            result.unionInPlace(_storage)
+            result.formUnion(_storage)
         } else {
             for case let obj as NSObject in self {
                 result.insert(obj)
@@ -283,7 +283,7 @@
     public func setByAddingObjectsFromArray(_ other: [AnyObject]) -> Set<NSObject> {
         var result = Set<NSObject>(minimumCapacity: count)
         if self.dynamicType === NSSet.self || self.dynamicType === NSMutableSet.self {
-            result.unionInPlace(_storage)
+            result.formUnion(_storage)
         } else {
             for case let obj as NSObject in self {
                 result.insert(obj)
@@ -400,7 +400,7 @@
     
     public func intersectSet(_ otherSet: Set<NSObject>) {
         if self.dynamicType === NSMutableSet.self {
-            _storage.intersectInPlace(otherSet)
+            _storage.formIntersection(otherSet)
         } else {
             for case let obj as NSObject in self where !otherSet.contains(obj) {
                 removeObject(obj)
@@ -410,7 +410,7 @@
     
     public func minusSet(_ otherSet: Set<NSObject>) {
         if self.dynamicType === NSMutableSet.self {
-            _storage.subtractInPlace(otherSet)
+            _storage.subtract(otherSet)
         } else {
             otherSet.forEach(removeObject)
         }
@@ -426,7 +426,7 @@
     
     public func unionSet(_ otherSet: Set<NSObject>) {
         if self.dynamicType === NSMutableSet.self {
-            _storage.unionInPlace(otherSet)
+            _storage.formUnion(otherSet)
         } else {
             otherSet.forEach(addObject)
         }
diff --git a/Foundation/NSSortDescriptor.swift b/Foundation/NSSortDescriptor.swift
index 8812f9a..2afba22 100644
--- a/Foundation/NSSortDescriptor.swift
+++ b/Foundation/NSSortDescriptor.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSSpecialValue.swift b/Foundation/NSSpecialValue.swift
index b8833c9..3c08f63 100644
--- a/Foundation/NSSpecialValue.swift
+++ b/Foundation/NSSpecialValue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -121,7 +121,7 @@
     
     override var objCType : UnsafePointer<Int8> {
         let typeName = NSSpecialValue._objCTypeFromType(_value.dynamicType)
-        return typeName!.bridge().UTF8String! // leaky
+        return typeName!.bridge().utf8String! // leaky
     }
     
     override var classForCoder: AnyClass {
diff --git a/Foundation/NSStream.swift b/Foundation/NSStream.swift
index cd54956..3134112 100644
--- a/Foundation/NSStream.swift
+++ b/Foundation/NSStream.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSString.swift b/Foundation/NSString.swift
index e709692..22f6475 100644
--- a/Foundation/NSString.swift
+++ b/Foundation/NSString.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -52,8 +52,8 @@
     public let rawValue : UInt
     public init(rawValue: UInt) { self.rawValue = rawValue }
     
-    public static let AllowLossy = NSStringEncodingConversionOptions(rawValue: 1)
-    public static let ExternalRepresentation = NSStringEncodingConversionOptions(rawValue: 2)
+    public static let allowLossy = NSStringEncodingConversionOptions(rawValue: 1)
+    public static let externalRepresentation = NSStringEncodingConversionOptions(rawValue: 2)
     internal static let FailOnPartialEncodingConversion = NSStringEncodingConversionOptions(rawValue: 1 << 20)
 }
 
@@ -61,14 +61,14 @@
     public let rawValue : UInt
     public init(rawValue: UInt) { self.rawValue = rawValue }
     
-    public static let ByLines = NSStringEnumerationOptions(rawValue: 0)
-    public static let ByParagraphs = NSStringEnumerationOptions(rawValue: 1)
-    public static let ByComposedCharacterSequences = NSStringEnumerationOptions(rawValue: 2)
-    public static let ByWords = NSStringEnumerationOptions(rawValue: 3)
-    public static let BySentences = NSStringEnumerationOptions(rawValue: 4)
-    public static let Reverse = NSStringEnumerationOptions(rawValue: 1 << 8)
-    public static let SubstringNotRequired = NSStringEnumerationOptions(rawValue: 1 << 9)
-    public static let Localized = NSStringEnumerationOptions(rawValue: 1 << 10)
+    public static let byLines = NSStringEnumerationOptions(rawValue: 0)
+    public static let byParagraphs = NSStringEnumerationOptions(rawValue: 1)
+    public static let byComposedCharacterSequences = NSStringEnumerationOptions(rawValue: 2)
+    public static let byWords = NSStringEnumerationOptions(rawValue: 3)
+    public static let bySentences = NSStringEnumerationOptions(rawValue: 4)
+    public static let reverse = NSStringEnumerationOptions(rawValue: 1 << 8)
+    public static let substringNotRequired = NSStringEnumerationOptions(rawValue: 1 << 9)
+    public static let localized = NSStringEnumerationOptions(rawValue: 1 << 10)
     
     internal static let ForceFullTokens = NSStringEnumerationOptions(rawValue: 1 << 20)
 }
@@ -120,21 +120,21 @@
     public let rawValue : UInt
     public init(rawValue: UInt) { self.rawValue = rawValue }
     
-    public static let CaseInsensitiveSearch = NSStringCompareOptions(rawValue: 1)
-    public static let LiteralSearch = NSStringCompareOptions(rawValue: 2)
-    public static let BackwardsSearch = NSStringCompareOptions(rawValue: 4)
-    public static let AnchoredSearch = NSStringCompareOptions(rawValue: 8)
-    public static let NumericSearch = NSStringCompareOptions(rawValue: 64)
-    public static let DiacriticInsensitiveSearch = NSStringCompareOptions(rawValue: 128)
-    public static let WidthInsensitiveSearch = NSStringCompareOptions(rawValue: 256)
-    public static let ForcedOrderingSearch = NSStringCompareOptions(rawValue: 512)
-    public static let RegularExpressionSearch = NSStringCompareOptions(rawValue: 1024)
+    public static let caseInsensitiveSearch = NSStringCompareOptions(rawValue: 1)
+    public static let literalSearch = NSStringCompareOptions(rawValue: 2)
+    public static let backwardsSearch = NSStringCompareOptions(rawValue: 4)
+    public static let anchoredSearch = NSStringCompareOptions(rawValue: 8)
+    public static let numericSearch = NSStringCompareOptions(rawValue: 64)
+    public static let diacriticInsensitiveSearch = NSStringCompareOptions(rawValue: 128)
+    public static let widthInsensitiveSearch = NSStringCompareOptions(rawValue: 256)
+    public static let forcedOrderingSearch = NSStringCompareOptions(rawValue: 512)
+    public static let regularExpressionSearch = NSStringCompareOptions(rawValue: 1024)
     
     internal func _cfValue(_ fixLiteral: Bool = false) -> CFStringCompareFlags {
 #if os(OSX) || os(iOS)
-        return contains(.LiteralSearch) || !fixLiteral ? CFStringCompareFlags(rawValue: rawValue) : CFStringCompareFlags(rawValue: rawValue).union(.compareNonliteral)
+        return contains(.literalSearch) || !fixLiteral ? CFStringCompareFlags(rawValue: rawValue) : CFStringCompareFlags(rawValue: rawValue).union(.compareNonliteral)
 #else
-        return contains(.LiteralSearch) || !fixLiteral ? CFStringCompareFlags(rawValue) : CFStringCompareFlags(rawValue) | UInt(kCFCompareNonliteral)
+        return contains(.literalSearch) || !fixLiteral ? CFStringCompareFlags(rawValue) : CFStringCompareFlags(rawValue) | UInt(kCFCompareNonliteral)
 #endif
     }
 }
@@ -169,12 +169,12 @@
     var used = 0
     var options: NSStringEncodingConversionOptions = []
     if externalRep {
-        options.unionInPlace(.ExternalRepresentation)
+        options.formUnion(.externalRepresentation)
     }
     if lossy {
-        options.unionInPlace(.AllowLossy)
+        options.formUnion(.allowLossy)
     }
-    if !str.getBytes(nil, maxLength: Int.max - 1, usedLength: &cLength, encoding: encoding, options: options, range: theRange, remainingRange: nil) {
+    if !str.getBytes(nil, maxLength: Int.max - 1, usedLength: &cLength, encoding: encoding, options: options, range: theRange, remaining: nil) {
         if fatalOnError {
             fatalError("Conversion on encoding failed")
         }
@@ -182,7 +182,7 @@
     }
     
     let buffer = malloc(cLength + 1)
-    if !str.getBytes(buffer, maxLength: cLength, usedLength: &used, encoding: encoding, options: options, range: theRange, remainingRange: nil) {
+    if !str.getBytes(buffer, maxLength: cLength, usedLength: &used, encoding: encoding, options: options, range: theRange, remaining: nil) {
         fatalError("Internal inconsistency; previously claimed getBytes returned success but failed with similar invocation")
     }
     
@@ -217,7 +217,7 @@
         }
     }
     
-    public func characterAtIndex(_ index: Int) -> unichar {
+    public func character(at index: Int) -> unichar {
         if self.dynamicType === NSString.self || self.dynamicType === NSMutableString.self {
             let start = _storage.utf16.startIndex
             return _storage.utf16[start.advanced(by: index)]
@@ -347,7 +347,7 @@
   
     public override func isEqual(_ object: AnyObject?) -> Bool {
         guard let string = (object as? NSString)?._swiftObject else { return false }
-        return self.isEqualToString(string)
+        return self.isEqual(to: string)
     }
     
     public override var description: String {
@@ -362,28 +362,28 @@
 extension NSString {
     public func getCharacters(_ buffer: UnsafeMutablePointer<unichar>, range: NSRange) {
         for idx in 0..<range.length {
-            buffer[idx] = characterAtIndex(idx + range.location)
+            buffer[idx] = character(at: idx + range.location)
         }
     }
     
-    public func substringFromIndex(_ from: Int) -> String {
+    public func substring(from: Int) -> String {
         if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
             return String(_storage.utf16.suffix(from: _storage.utf16.startIndex.advanced(by: from)))
         } else {
-            return substringWithRange(NSMakeRange(from, length - from))
+            return substring(with: NSMakeRange(from, length - from))
         }
     }
     
-    public func substringToIndex(_ to: Int) -> String {
+    public func substring(to: Int) -> String {
         if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
             return String(_storage.utf16.prefix(upTo: _storage.utf16.startIndex
             .advanced(by: to)))
         } else {
-            return substringWithRange(NSMakeRange(0, to))
+            return substring(with: NSMakeRange(0, to))
         }
     }
     
-    public func substringWithRange(_ range: NSRange) -> String {
+    public func substring(with range: NSRange) -> String {
         if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
             let start = _storage.utf16.startIndex
             let min = start.advanced(by: range.location)
@@ -422,7 +422,7 @@
     }
     
     public func caseInsensitiveCompare(_ string: String) -> NSComparisonResult {
-        return compare(string, options: .CaseInsensitiveSearch, range: NSMakeRange(0, length))
+        return compare(string, options: .caseInsensitiveSearch, range: NSMakeRange(0, length))
     }
     
     public func localizedCompare(_ string: String) -> NSComparisonResult {
@@ -430,32 +430,32 @@
     }
     
     public func localizedCaseInsensitiveCompare(_ string: String) -> NSComparisonResult {
-        return compare(string, options: .CaseInsensitiveSearch, range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
+        return compare(string, options: .caseInsensitiveSearch, range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
     }
     
     public func localizedStandardCompare(_ string: String) -> NSComparisonResult {
-        return compare(string, options: [.CaseInsensitiveSearch, .NumericSearch, .WidthInsensitiveSearch, .ForcedOrderingSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
+        return compare(string, options: [.caseInsensitiveSearch, .numericSearch, .widthInsensitiveSearch, .forcedOrderingSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
     }
     
-    public func isEqualToString(_ aString: String) -> Bool {
+    public func isEqual(to aString: String) -> Bool {
         if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
             return _storage == aString
         } else {
-            return length == aString.length && compare(aString, options: .LiteralSearch, range: NSMakeRange(0, length)) == .OrderedSame
+            return length == aString.length && compare(aString, options: .literalSearch, range: NSMakeRange(0, length)) == .OrderedSame
         }
     }
     
     public func hasPrefix(_ str: String) -> Bool {
-        return rangeOfString(str, options: .AnchoredSearch, range: NSMakeRange(0, length)).location != NSNotFound
+        return range(of: str, options: .anchoredSearch, range: NSMakeRange(0, length)).location != NSNotFound
     }
     
     public func hasSuffix(_ str: String) -> Bool {
-        return rangeOfString(str, options: [.AnchoredSearch, .BackwardsSearch], range: NSMakeRange(0, length)).location != NSNotFound
+        return range(of: str, options: [.anchoredSearch, .backwardsSearch], range: NSMakeRange(0, length)).location != NSNotFound
     }
     
-    public func commonPrefixWithString(_ str: String, options mask: NSStringCompareOptions) -> String {
+    public func commonPrefix(with str: String, options mask: NSStringCompareOptions = []) -> String {
         var currentSubstring: CFMutableString?
-        let isLiteral = mask.contains(.LiteralSearch)
+        let isLiteral = mask.contains(.literalSearch)
         var lastMatch = NSRange()
         let selfLen = length
         let otherLen = str.length
@@ -474,7 +474,7 @@
         return arrayBuffer.withUnsafeMutablePointerOrAllocation(selfLen, fastpath: UnsafeMutablePointer<unichar>(_fastContents)) { (selfChars: UnsafeMutablePointer<unichar>) -> String in
             // Now do the binary search. Note that the probe value determines the length of the substring to check.
             while true {
-                let range = NSMakeRange(0, isLiteral ? probe + 1 : NSMaxRange(rangeOfComposedCharacterSequenceAtIndex(probe))) // Extend the end of the composed char sequence
+                let range = NSMakeRange(0, isLiteral ? probe + 1 : NSMaxRange(rangeOfComposedCharacterSequence(at: probe))) // Extend the end of the composed char sequence
                 if range.length > numCharsBuffered { // Buffer more characters if needed
                     getCharacters(selfChars, range: NSMakeRange(numCharsBuffered, range.length - numCharsBuffered))
                     numCharsBuffered = range.length
@@ -484,7 +484,7 @@
                 } else {
                     CFStringSetExternalCharactersNoCopy(currentSubstring, selfChars, range.length, range.length)
                 }
-                if other.rangeOfString(currentSubstring!._swiftObject, options: mask.union(.AnchoredSearch), range: NSMakeRange(0, otherLen)).length != 0 { // Match
+                if other.range(of: currentSubstring!._swiftObject, options: mask.union(.anchoredSearch), range: NSMakeRange(0, otherLen)).length != 0 { // Match
                     lastMatch = range
                     low = probe + 1
                 } else {
@@ -495,55 +495,55 @@
                 }
                 probe = (low + high) / 2
             }
-            return lastMatch.length != 0 ? substringWithRange(lastMatch) : ""
+            return lastMatch.length != 0 ? substring(with: lastMatch) : ""
         }
     }
     
-    public func containsString(_ str: String) -> Bool {
-        return rangeOfString(str, options: [], range: NSMakeRange(0, length), locale: nil).location != NSNotFound
+    public func contains(_ str: String) -> Bool {
+        return range(of: str, options: [], range: NSMakeRange(0, length), locale: nil).location != NSNotFound
     }
     
-    public func localizedCaseInsensitiveContainsString(_ str: String) -> Bool {
-        return rangeOfString(str, options: .CaseInsensitiveSearch, range: NSMakeRange(0, length), locale: NSLocale.currentLocale()).location != NSNotFound
+    public func localizedCaseInsensitiveContains(_ str: String) -> Bool {
+        return range(of: str, options: .caseInsensitiveSearch, range: NSMakeRange(0, length), locale: NSLocale.currentLocale()).location != NSNotFound
     }
     
-    public func localizedStandardContainsString(_ str: String) -> Bool {
-        return rangeOfString(str, options: [.CaseInsensitiveSearch, .DiacriticInsensitiveSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale()).location != NSNotFound
+    public func localizedStandardContains(_ str: String) -> Bool {
+        return range(of: str, options: [.caseInsensitiveSearch, .diacriticInsensitiveSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale()).location != NSNotFound
     }
     
-    public func localizedStandardRangeOfString(_ str: String) -> NSRange {
-        return rangeOfString(str, options: [.CaseInsensitiveSearch, .DiacriticInsensitiveSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
+    public func localizedStandardRange(of str: String) -> NSRange {
+        return range(of: str, options: [.caseInsensitiveSearch, .diacriticInsensitiveSearch], range: NSMakeRange(0, length), locale: NSLocale.currentLocale())
     }
     
-    public func rangeOfString(_ searchString: String) -> NSRange {
-        return rangeOfString(searchString, options: [], range: NSMakeRange(0, length), locale: nil)
+    public func range(of searchString: String) -> NSRange {
+        return range(of: searchString, options: [], range: NSMakeRange(0, length), locale: nil)
     }
     
-    public func rangeOfString(_ searchString: String, options mask: NSStringCompareOptions) -> NSRange {
-        return rangeOfString(searchString, options: mask, range: NSMakeRange(0, length), locale: nil)
+    public func range(of searchString: String, options mask: NSStringCompareOptions = []) -> NSRange {
+        return range(of: searchString, options: mask, range: NSMakeRange(0, length), locale: nil)
     }
     
-    public func rangeOfString(_ searchString: String, options mask: NSStringCompareOptions, range searchRange: NSRange) -> NSRange {
-        return rangeOfString(searchString, options: mask, range: searchRange, locale: nil)
+    public func range(of searchString: String, options mask: NSStringCompareOptions = [], range searchRange: NSRange) -> NSRange {
+        return range(of: searchString, options: mask, range: searchRange, locale: nil)
     }
     
     internal func _rangeOfRegularExpressionPattern(regex pattern: String, options mask: NSStringCompareOptions, range searchRange: NSRange, locale: NSLocale?) -> NSRange {
         var matchedRange = NSMakeRange(NSNotFound, 0)
-        let regexOptions: NSRegularExpressionOptions = mask.contains(.CaseInsensitiveSearch) ? .caseInsensitive : []
-        let matchingOptions: NSMatchingOptions = mask.contains(.AnchoredSearch) ? .anchored : []
+        let regexOptions: NSRegularExpressionOptions = mask.contains(.caseInsensitiveSearch) ? .caseInsensitive : []
+        let matchingOptions: NSMatchingOptions = mask.contains(.anchoredSearch) ? .anchored : []
         if let regex = _createRegexForPattern(pattern, regexOptions) {
             matchedRange = regex.rangeOfFirstMatch(in: _swiftObject, options: matchingOptions, range: searchRange)
         }
         return matchedRange
     }
     
-    public func rangeOfString(_ searchString: String, options mask: NSStringCompareOptions, range searchRange: NSRange, locale: NSLocale?) -> NSRange {
+    public func range(of searchString: String, options mask: NSStringCompareOptions = [], range searchRange: NSRange, locale: NSLocale?) -> NSRange {
         let findStrLen = searchString.length
         let len = length
         
         precondition(searchRange.length <= len && searchRange.location <= len - searchRange.length, "Bounds Range {\(searchRange.location), \(searchRange.length)} out of bounds; string length \(len)")
         
-        if mask.contains(.RegularExpressionSearch) {
+        if mask.contains(.regularExpressionSearch) {
             return _rangeOfRegularExpressionPattern(regex: searchString, options: mask, range:searchRange, locale: locale)
         }
         
@@ -566,15 +566,15 @@
         }
     }
     
-    public func rangeOfCharacterFromSet(_ searchSet: NSCharacterSet) -> NSRange {
-        return rangeOfCharacterFromSet(searchSet, options: [], range: NSMakeRange(0, length))
+    public func rangeOfCharacter(from searchSet: NSCharacterSet) -> NSRange {
+        return rangeOfCharacter(from: searchSet, options: [], range: NSMakeRange(0, length))
     }
     
-    public func rangeOfCharacterFromSet(_ searchSet: NSCharacterSet, options mask: NSStringCompareOptions) -> NSRange {
-        return rangeOfCharacterFromSet(searchSet, options: mask, range: NSMakeRange(0, length))
+    public func rangeOfCharacter(from searchSet: NSCharacterSet, options mask: NSStringCompareOptions = []) -> NSRange {
+        return rangeOfCharacter(from: searchSet, options: mask, range: NSMakeRange(0, length))
     }
     
-    public func rangeOfCharacterFromSet(_ searchSet: NSCharacterSet, options mask: NSStringCompareOptions, range searchRange: NSRange) -> NSRange {
+    public func rangeOfCharacter(from searchSet: NSCharacterSet, options mask: NSStringCompareOptions = [], range searchRange: NSRange) -> NSRange {
         let len = length
         
         precondition(searchRange.length <= len && searchRange.location <= len - searchRange.length, "Bounds Range {\(searchRange.location), \(searchRange.length)} out of bounds; string length \(len)")
@@ -590,19 +590,19 @@
         }
     }
     
-    public func rangeOfComposedCharacterSequenceAtIndex(_ index: Int) -> NSRange {
+    public func rangeOfComposedCharacterSequence(at index: Int) -> NSRange {
         let range = CFStringGetRangeOfCharacterClusterAtIndex(_cfObject, index, kCFStringComposedCharacterCluster)
         return NSMakeRange(range.location, range.length)
     }
     
-    public func rangeOfComposedCharacterSequencesForRange(_ range: NSRange) -> NSRange {
+    public func rangeOfComposedCharacterSequences(for range: NSRange) -> NSRange {
         let length = self.length
         var start: Int
         var end: Int
         if range.location == length {
             start = length
         } else {
-            start = rangeOfComposedCharacterSequenceAtIndex(range.location).location
+            start = rangeOfComposedCharacterSequence(at: range.location).location
         }
         var endOfRange = NSMaxRange(range)
         if endOfRange == length {
@@ -611,19 +611,19 @@
             if range.length > 0 {
                 endOfRange = endOfRange - 1 // We want 0-length range to be treated same as 1-length range.
             }
-            end = NSMaxRange(rangeOfComposedCharacterSequenceAtIndex(endOfRange))
+            end = NSMaxRange(rangeOfComposedCharacterSequence(at: endOfRange))
         }
         return NSMakeRange(start, end - start)
     }
     
-    public func stringByAppendingString(_ aString: String) -> String {
+    public func appending(_ aString: String) -> String {
         return _swiftObject + aString
     }
     
     public var doubleValue: Double {
         var start: Int = 0
         var result = 0.0
-        _swiftObject.scan(NSCharacterSet.whitespaceCharacterSet(), locale: nil, locationToScanFrom: &start) { (value: Double) -> Void in
+        _swiftObject.scan(NSCharacterSet.whitespaces(), locale: nil, locationToScanFrom: &start) { (value: Double) -> Void in
             result = value
         }
         return result
@@ -632,7 +632,7 @@
     public var floatValue: Float {
         var start: Int = 0
         var result: Float = 0.0
-        _swiftObject.scan(NSCharacterSet.whitespaceCharacterSet(), locale: nil, locationToScanFrom: &start) { (value: Float) -> Void in
+        _swiftObject.scan(NSCharacterSet.whitespaces(), locale: nil, locationToScanFrom: &start) { (value: Float) -> Void in
             result = value
         }
         return result
@@ -656,53 +656,53 @@
     public var boolValue: Bool {
         let scanner = NSScanner(string: _swiftObject)
         // skip initial whitespace if present
-        scanner.scanCharactersFromSet(NSCharacterSet.whitespaceCharacterSet())
+        scanner.scanCharactersFromSet(NSCharacterSet.whitespaces())
         // scan a single optional '+' or '-' character, followed by zeroes
         if scanner.scanString(string: "+") == nil {
             scanner.scanString(string: "-")
         }
         // scan any following zeroes
-        scanner.scanCharactersFromSet(NSCharacterSet(charactersInString: "0"))
-        return scanner.scanCharactersFromSet(NSCharacterSet(charactersInString: "tTyY123456789")) != nil
+        scanner.scanCharactersFromSet(NSCharacterSet(charactersIn: "0"))
+        return scanner.scanCharactersFromSet(NSCharacterSet(charactersIn: "tTyY123456789")) != nil
     }
     
-    public var uppercaseString: String {
-        return uppercaseStringWithLocale(nil)
+    public var uppercased: String {
+        return uppercased(with: nil)
     }
 
-    public var lowercaseString: String {
-        return lowercaseStringWithLocale(nil)
+    public var lowercased: String {
+        return lowercased(with: nil)
     }
     
-    public var capitalizedString: String {
-        return capitalizedStringWithLocale(nil)
+    public var capitalized: String {
+        return capitalized(with: nil)
     }
     
-    public var localizedUppercaseString: String {
-        return uppercaseStringWithLocale(NSLocale.currentLocale())
+    public var localizedUppercase: String {
+        return uppercased(with: NSLocale.currentLocale())
     }
     
-    public var localizedLowercaseString: String {
-        return lowercaseStringWithLocale(NSLocale.currentLocale())
+    public var localizedLowercase: String {
+        return lowercased(with: NSLocale.currentLocale())
     }
     
-    public var localizedCapitalizedString: String {
-        return capitalizedStringWithLocale(NSLocale.currentLocale())
+    public var localizedCapitalized: String {
+        return capitalized(with: NSLocale.currentLocale())
     }
     
-    public func uppercaseStringWithLocale(_ locale: NSLocale?) -> String {
+    public func uppercased(with locale: NSLocale?) -> String {
         let mutableCopy = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, self._cfObject)
         CFStringUppercase(mutableCopy, locale?._cfObject ?? nil)
         return mutableCopy._swiftObject
     }
 
-    public func lowercaseStringWithLocale(_ locale: NSLocale?) -> String {
+    public func lowercased(with locale: NSLocale?) -> String {
         let mutableCopy = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, self._cfObject)
         CFStringLowercase(mutableCopy, locale?._cfObject ?? nil)
         return mutableCopy._swiftObject
     }
     
-    public func capitalizedStringWithLocale(_ locale: NSLocale?) -> String {
+    public func capitalized(with locale: NSLocale?) -> String {
         let mutableCopy = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, self._cfObject)
         CFStringCapitalize(mutableCopy, locale?._cfObject ?? nil)
         return mutableCopy._swiftObject
@@ -786,39 +786,39 @@
         }
     }
     
-    public func getLineStart(_ startPtr: UnsafeMutablePointer<Int>?, end lineEndPtr: UnsafeMutablePointer<Int>?, contentsEnd contentsEndPtr: UnsafeMutablePointer<Int>?, forRange range: NSRange) {
+    public func getLineStart(_ startPtr: UnsafeMutablePointer<Int>?, end lineEndPtr: UnsafeMutablePointer<Int>?, contentsEnd contentsEndPtr: UnsafeMutablePointer<Int>?, for range: NSRange) {
         _getBlockStart(startPtr, end: lineEndPtr, contentsEnd: contentsEndPtr, forRange: range, stopAtLineSeparators: true)
     }
     
-    public func lineRangeForRange(_ range: NSRange) -> NSRange {
+    public func lineRange(for range: NSRange) -> NSRange {
         var start = 0
         var lineEnd = 0
-        getLineStart(&start, end: &lineEnd, contentsEnd: nil, forRange: range)
+        getLineStart(&start, end: &lineEnd, contentsEnd: nil, for: range)
         return NSMakeRange(start, lineEnd - start)
     }
     
-    public func getParagraphStart(_ startPtr: UnsafeMutablePointer<Int>?, end parEndPtr: UnsafeMutablePointer<Int>?, contentsEnd contentsEndPtr: UnsafeMutablePointer<Int>?, forRange range: NSRange) {
+    public func getParagraphStart(_ startPtr: UnsafeMutablePointer<Int>?, end parEndPtr: UnsafeMutablePointer<Int>?, contentsEnd contentsEndPtr: UnsafeMutablePointer<Int>?, for range: NSRange) {
         _getBlockStart(startPtr, end: parEndPtr, contentsEnd: contentsEndPtr, forRange: range, stopAtLineSeparators: false)
     }
     
-    public func paragraphRangeForRange(_ range: NSRange) -> NSRange {
+    public func paragraphRange(for range: NSRange) -> NSRange {
         var start = 0
         var parEnd = 0
-        getParagraphStart(&start, end: &parEnd, contentsEnd: nil, forRange: range)
+        getParagraphStart(&start, end: &parEnd, contentsEnd: nil, for: range)
         return NSMakeRange(start, parEnd - start)
     }
     
-    public func enumerateSubstringsInRange(_ range: NSRange, options opts: NSStringEnumerationOptions, usingBlock block: (String?, NSRange, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
+    public func enumerateSubstrings(in range: NSRange, options opts: NSStringEnumerationOptions = [], using block: (String?, NSRange, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
         NSUnimplemented()
     }
     
-    public func enumerateLinesUsingBlock(_ block: (String, UnsafeMutablePointer<ObjCBool>) -> Void) {
-        enumerateSubstringsInRange(NSMakeRange(0, length), options:.ByLines) { substr, substrRange, enclosingRange, stop in
+    public func enumerateLines(_ block: (String, UnsafeMutablePointer<ObjCBool>) -> Void) {
+        enumerateSubstrings(in: NSMakeRange(0, length), options:.byLines) { substr, substrRange, enclosingRange, stop in
             block(substr!, stop)
         }
     }
     
-    public var UTF8String: UnsafePointer<Int8>? {
+    public var utf8String: UnsafePointer<Int8>? {
         return _bytesInEncoding(self, NSUTF8StringEncoding, false, false, false)
     }
     
@@ -827,13 +827,13 @@
     }
     
     public var smallestEncoding: UInt {
-        if canBeConvertedToEncoding(NSASCIIStringEncoding) {
+        if canBeConverted(to: NSASCIIStringEncoding) {
             return NSASCIIStringEncoding
         }
         return NSUnicodeStringEncoding
     }
     
-    public func dataUsingEncoding(_ encoding: UInt, allowLossyConversion lossy: Bool) -> NSData? {
+    public func data(using encoding: UInt, allowLossyConversion lossy: Bool) -> NSData? {
         let len = length
         var reqSize = 0
         
@@ -860,18 +860,18 @@
         return nil
     }
     
-    public func dataUsingEncoding(_ encoding: UInt) -> NSData? {
-        return dataUsingEncoding(encoding, allowLossyConversion: false)
+    public func data(using encoding: UInt) -> NSData? {
+        return data(using: encoding, allowLossyConversion: false)
     }
     
-    public func canBeConvertedToEncoding(_ encoding: UInt) -> Bool {
+    public func canBeConverted(to encoding: UInt) -> Bool {
         if encoding == NSUnicodeStringEncoding || encoding == NSNonLossyASCIIStringEncoding || encoding == NSUTF8StringEncoding {
             return true
         }
         return __CFStringEncodeByteStream(_cfObject, 0, length, false, CFStringConvertNSStringEncodingToEncoding(encoding), 0, nil, 0, nil) == length
     }
-    
-    public func cStringUsingEncoding(_ encoding: UInt) -> UnsafePointer<Int8>? {
+   
+    public func cString(using encoding: UInt) -> UnsafePointer<Int8>? { 
         return _bytesInEncoding(self, encoding, false, false, false)
     }
     
@@ -886,22 +886,22 @@
                 return true
             }
         }
-        if getBytes(UnsafeMutablePointer<Void>(buffer), maxLength: maxBufferCount, usedLength: &used, encoding: encoding, options: [], range: NSMakeRange(0, self.length), remainingRange: nil) {
+        if getBytes(UnsafeMutablePointer<Void>(buffer), maxLength: maxBufferCount, usedLength: &used, encoding: encoding, options: [], range: NSMakeRange(0, self.length), remaining: nil) {
             buffer.advanced(by: used).initialize(with: 0)
             return true
         }
         return false
     }
     
-    public func getBytes(_ buffer: UnsafeMutablePointer<Void>?, maxLength maxBufferCount: Int, usedLength usedBufferCount: UnsafeMutablePointer<Int>?, encoding: UInt, options: NSStringEncodingConversionOptions, range: NSRange, remainingRange leftover: NSRangePointer?) -> Bool {
+    public func getBytes(_ buffer: UnsafeMutablePointer<Void>?, maxLength maxBufferCount: Int, usedLength usedBufferCount: UnsafeMutablePointer<Int>?, encoding: UInt, options: NSStringEncodingConversionOptions = [], range: NSRange, remaining leftover: NSRangePointer?) -> Bool {
         var totalBytesWritten = 0
         var numCharsProcessed = 0
         let cfStringEncoding = CFStringConvertNSStringEncodingToEncoding(encoding)
         var result = true
         if length > 0 {
             if CFStringIsEncodingAvailable(cfStringEncoding) {
-                let lossyOk = options.contains(.AllowLossy)
-                let externalRep = options.contains(.ExternalRepresentation)
+                let lossyOk = options.contains(.allowLossy)
+                let externalRep = options.contains(.externalRepresentation)
                 let failOnPartial = options.contains(.FailOnPartialEncodingConversion)
                 numCharsProcessed = __CFStringEncodeByteStream(_cfObject, range.location, range.length, externalRep, cfStringEncoding, lossyOk ? (encoding == NSASCIIStringEncoding ? 0xFF : 0x3F) : 0, UnsafeMutablePointer<UInt8>(buffer), buffer != nil ? maxBufferCount : 0, &totalBytesWritten)
                 if (failOnPartial && numCharsProcessed < range.length) || numCharsProcessed == 0 {
@@ -916,13 +916,13 @@
         return result
     }
     
-    public func maximumLengthOfBytesUsingEncoding(_ enc: UInt) -> Int {
+    public func maximumLengthOfBytes(using enc: UInt) -> Int {
         let cfEnc = CFStringConvertNSStringEncodingToEncoding(enc)
         let result = CFStringGetMaximumSizeForEncoding(length, cfEnc)
         return result == kCFNotFound ? 0 : result
     }
     
-    public func lengthOfBytesUsingEncoding(_ enc: UInt) -> Int {
+    public func lengthOfBytes(using enc: UInt) -> Int {
         let len = length
         var numBytes: CFIndex = 0
         let cfEnc = CFStringConvertNSStringEncodingToEncoding(enc)
@@ -957,7 +957,7 @@
         return once.encodings
     }
     
-    public class func localizedNameOfStringEncoding(_ encoding: UInt) -> String {
+    public class func localizedName(of encoding: UInt) -> String {
         if let theString = CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(encoding)) {
             // TODO: read the localized version from the Foundation "bundle"
             return theString._swiftObject
@@ -998,9 +998,32 @@
         return string._swiftObject
     }
     
-    public func componentsSeparatedByString(_ separator: String) -> [String] {
+    public func components(separatedBy separator: String) -> [String] {
         let len = length
-        var range = rangeOfString(separator, options: [], range: NSMakeRange(0, len))
+        var lrange = range(of: separator, options: [], range: NSMakeRange(0, len))
+        if lrange.length == 0 {
+            return [_swiftObject]
+        } else {
+            var array = [String]()
+            var srange = NSMakeRange(0, len)
+            while true {
+                let trange = NSMakeRange(srange.location, lrange.location - srange.location)
+                array.append(substring(with: trange))
+                srange.location = lrange.location + lrange.length
+                srange.length = len - srange.location
+                lrange = range(of: separator, options: [], range: srange)
+                if lrange.length == 0 {
+                    break
+                }
+            }
+            array.append(substring(with: srange))
+            return array
+        }
+    }
+    
+    public func components(separatedBy separator: NSCharacterSet) -> [String] {
+        let len = length
+        var range = rangeOfCharacter(from: separator, options: [], range: NSMakeRange(0, len))
         if range.length == 0 {
             return [_swiftObject]
         } else {
@@ -1008,43 +1031,20 @@
             var srange = NSMakeRange(0, len)
             while true {
                 let trange = NSMakeRange(srange.location, range.location - srange.location)
-                array.append(substringWithRange(trange))
+                array.append(substring(with: trange))
                 srange.location = range.location + range.length
                 srange.length = len - srange.location
-                range = rangeOfString(separator, options: [], range: srange)
+                range = rangeOfCharacter(from: separator, options: [], range: srange)
                 if range.length == 0 {
                     break
                 }
             }
-            array.append(substringWithRange(srange))
+            array.append(substring(with: srange))
             return array
         }
     }
     
-    public func componentsSeparatedByCharactersInSet(_ separator: NSCharacterSet) -> [String] {
-        let len = length
-        var range = rangeOfCharacterFromSet(separator, options: [], range: NSMakeRange(0, len))
-        if range.length == 0 {
-            return [_swiftObject]
-        } else {
-            var array = [String]()
-            var srange = NSMakeRange(0, len)
-            while true {
-                let trange = NSMakeRange(srange.location, range.location - srange.location)
-                array.append(substringWithRange(trange))
-                srange.location = range.location + range.length
-                srange.length = len - srange.location
-                range = rangeOfCharacterFromSet(separator, options: [], range: srange)
-                if range.length == 0 {
-                    break
-                }
-            }
-            array.append(substringWithRange(srange))
-            return array
-        }
-    }
-    
-    public func stringByTrimmingCharactersInSet(_ set: NSCharacterSet) -> String {
+    public func trimmingCharacters(in set: NSCharacterSet) -> String {
         let len = length
         var buf = _NSStringBuffer(string: self, start: 0, end: len)
         while !buf.isAtEnd && set.characterIsMember(buf.currentCharacter) {
@@ -1061,16 +1061,16 @@
                 buf.rewind()
             }
             let endOfNonTrimmedRange = buf.location
-            return substringWithRange(NSMakeRange(startOfNonTrimmedRange, endOfNonTrimmedRange + 1 - startOfNonTrimmedRange))
+            return substring(with: NSMakeRange(startOfNonTrimmedRange, endOfNonTrimmedRange + 1 - startOfNonTrimmedRange))
         } else {
-            return substringWithRange(NSMakeRange(startOfNonTrimmedRange, 1))
+            return substring(with: NSMakeRange(startOfNonTrimmedRange, 1))
         }
     }
     
-    public func stringByPaddingToLength(_ newLength: Int, withString padString: String, startingAtIndex padIndex: Int) -> String {
+    public func padding(toLength newLength: Int, withPad padString: String, startingAt padIndex: Int) -> String {
         let len = length
         if newLength <= len {	// The simple cases (truncation)
-            return newLength == len ? _swiftObject : substringWithRange(NSMakeRange(0, newLength))
+            return newLength == len ? _swiftObject : substring(with: NSMakeRange(0, newLength))
         }
         let padLen = padString.length
         if padLen < 1 {
@@ -1085,7 +1085,7 @@
         return mStr._swiftObject
     }
     
-    public func stringByFoldingWithOptions(_ options: NSStringCompareOptions, locale: NSLocale?) -> String {
+    public func folding(_ options: NSStringCompareOptions = [], locale: NSLocale?) -> String {
         let string = CFStringCreateMutable(kCFAllocatorSystemDefault, 0)
         CFStringReplaceAll(string, self._cfObject)
         CFStringFold(string, options._cfValue(), locale?._cfObject)
@@ -1093,37 +1093,37 @@
     }
     
     internal func _stringByReplacingOccurrencesOfRegularExpressionPattern(_ pattern: String, withTemplate replacement: String, options: NSStringCompareOptions, range: NSRange) -> String {
-        let regexOptions: NSRegularExpressionOptions = options.contains(.CaseInsensitiveSearch) ? .caseInsensitive : []
-        let matchingOptions: NSMatchingOptions = options.contains(.AnchoredSearch) ? .anchored : []
+        let regexOptions: NSRegularExpressionOptions = options.contains(.caseInsensitiveSearch) ? .caseInsensitive : []
+        let matchingOptions: NSMatchingOptions = options.contains(.anchoredSearch) ? .anchored : []
         if let regex = _createRegexForPattern(pattern, regexOptions) {
             return regex.stringByReplacingMatches(in: _swiftObject, options: matchingOptions, range: range, withTemplate: replacement)
         }
         return ""
     }
     
-    public func stringByReplacingOccurrencesOfString(_ target: String, withString replacement: String, options: NSStringCompareOptions, range searchRange: NSRange) -> String {
-        if options.contains(.RegularExpressionSearch) {
+    public func replacingOccurrences(of target: String, with replacement: String, options: NSStringCompareOptions = [], range searchRange: NSRange) -> String {
+        if options.contains(.regularExpressionSearch) {
             return _stringByReplacingOccurrencesOfRegularExpressionPattern(target, withTemplate: replacement, options: options, range: searchRange)
         }
         let str = mutableCopyWithZone(nil) as! NSMutableString
-        if str.replaceOccurrencesOfString(target, withString: replacement, options: options, range: searchRange) == 0 {
+        if str.replaceOccurrences(of: target, with: replacement, options: options, range: searchRange) == 0 {
             return _swiftObject
         } else {
             return str._swiftObject
         }
     }
     
-    public func stringByReplacingOccurrencesOfString(_ target: String, withString replacement: String) -> String {
-        return stringByReplacingOccurrencesOfString(target, withString: replacement, options: [], range: NSMakeRange(0, length))
+    public func replacingOccurrences(of target: String, with replacement: String) -> String {
+        return replacingOccurrences(of: target, with: replacement, options: [], range: NSMakeRange(0, length))
     }
     
-    public func stringByReplacingCharactersInRange(_ range: NSRange, withString replacement: String) -> String {
+    public func replacingCharacters(in range: NSRange, with replacement: String) -> String {
         let str = mutableCopyWithZone(nil) as! NSMutableString
-        str.replaceCharactersInRange(range, withString: replacement)
+        str.replaceCharacters(in: range, with: replacement)
         return str._swiftObject
     }
     
-    public func stringByApplyingTransform(_ transform: String, reverse: Bool) -> String? {
+    public func applyingTransform(_ transform: String, reverse: Bool) -> String? {
         let string = CFStringCreateMutable(kCFAllocatorSystemDefault, 0)
         CFStringReplaceAll(string, _cfObject)
         if (CFStringTransform(string, nil, transform._cfObject, reverse)) {
@@ -1137,7 +1137,7 @@
         let length = self.length
         var numBytes = 0
         let theRange = NSMakeRange(0, length)
-        if !getBytes(nil, maxLength: Int.max - 1, usedLength: &numBytes, encoding: enc, options: [], range: theRange, remainingRange: nil) {
+        if !getBytes(nil, maxLength: Int.max - 1, usedLength: &numBytes, encoding: enc, options: [], range: theRange, remaining: nil) {
             throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.FileWriteInapplicableStringEncodingError.rawValue, userInfo: [
                 NSURLErrorKey: dest,
             ])
@@ -1145,7 +1145,7 @@
         let mData = NSMutableData(length: numBytes)!
         // The getBytes:... call should hopefully not fail, given it succeeded above, but check anyway (mutable string changing behind our back?)
         var used = 0
-        if !getBytes(mData.mutableBytes, maxLength: numBytes, usedLength: &used, encoding: enc, options: [], range: theRange, remainingRange: nil) {
+        if !getBytes(mData.mutableBytes, maxLength: numBytes, usedLength: &used, encoding: enc, options: [], range: theRange, remaining: nil) {
             throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.FileWriteUnknownError.rawValue, userInfo: [
                 NSURLErrorKey: dest,
             ])
@@ -1170,11 +1170,11 @@
         }
     }
     
-    public func writeToURL(_ url: NSURL, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws {
+    public func write(to url: NSURL, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws {
         try _writeTo(url, useAuxiliaryFile, enc)
     }
     
-    public func writeToFile(_ path: String, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws {
+    public func write(toFile path: String, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws {
         try _writeTo(NSURL(fileURLWithPath: path), useAuxiliaryFile, enc)
     }
     
@@ -1290,12 +1290,12 @@
 extension NSString : StringLiteralConvertible { }
 
 public class NSMutableString : NSString {
-    public func replaceCharactersInRange(_ range: NSRange, withString aString: String) {
+    public func replaceCharacters(in range: NSRange, with aString: String) {
         if self.dynamicType === NSString.self || self.dynamicType === NSMutableString.self {
             // this is incorrectly calculated for grapheme clusters that have a size greater than a single unichar
             let start = _storage.startIndex
-            let min = start.advanced(by: range.location)
-            let max = start.advanced(by: range.location + range.length)
+            let min = _storage.index(start, offsetBy: range.location)
+            let max = _storage.index(start, offsetBy: range.location + range.length)
             _storage.replaceSubrange(min..<max, with: aString)
         } else {
             NSRequiresConcreteImplementation()
@@ -1343,7 +1343,7 @@
         if self.dynamicType == NSMutableString.self {
             _storage.append(String._fromWellFormedCodeUnitSequence(UTF16.self, input: UnsafeBufferPointer(start: characters, count: length)))
         } else {
-            replaceCharactersInRange(NSMakeRange(self.length, 0), withString: String._fromWellFormedCodeUnitSequence(UTF16.self, input: UnsafeBufferPointer(start: characters, count: length)))
+            replaceCharacters(in: NSMakeRange(self.length, 0), with: String._fromWellFormedCodeUnitSequence(UTF16.self, input: UnsafeBufferPointer(start: characters, count: length)))
         }
     }
     
@@ -1355,38 +1355,38 @@
 }
 
 extension NSMutableString {
-    public func insertString(_ aString: String, atIndex loc: Int) {
-        replaceCharactersInRange(NSMakeRange(loc, 0), withString: aString)
+    public func insert(_ aString: String, at loc: Int) {
+        replaceCharacters(in: NSMakeRange(loc, 0), with: aString)
     }
     
-    public func deleteCharactersInRange(_ range: NSRange) {
-        replaceCharactersInRange(range, withString: "")
+    public func deleteCharacters(in range: NSRange) {
+        replaceCharacters(in: range, with: "")
     }
     
-    public func appendString(_ aString: String) {
-        replaceCharactersInRange(NSMakeRange(length, 0), withString: aString)
+    public func append(_ aString: String) {
+        replaceCharacters(in: NSMakeRange(length, 0), with: aString)
     }
     
     public func setString(_ aString: String) {
-        replaceCharactersInRange(NSMakeRange(0, length), withString: aString)
+        replaceCharacters(in: NSMakeRange(0, length), with: aString)
     }
     
     internal func _replaceOccurrencesOfRegularExpressionPattern(_ pattern: String, withTemplate replacement: String, options: NSStringCompareOptions, range searchRange: NSRange) -> Int {
-        let regexOptions: NSRegularExpressionOptions = options.contains(.CaseInsensitiveSearch) ? .caseInsensitive : []
-        let matchingOptions: NSMatchingOptions = options.contains(.AnchoredSearch) ? .anchored : []
+        let regexOptions: NSRegularExpressionOptions = options.contains(.caseInsensitiveSearch) ? .caseInsensitive : []
+        let matchingOptions: NSMatchingOptions = options.contains(.anchoredSearch) ? .anchored : []
         if let regex = _createRegexForPattern(pattern, regexOptions) {
             return regex.replaceMatches(in: self, options: matchingOptions, range: searchRange, withTemplate: replacement)
         }
         return 0
     }
     
-    public func replaceOccurrencesOfString(_ target: String, withString replacement: String, options: NSStringCompareOptions, range searchRange: NSRange) -> Int {
-        let backwards = options.contains(.BackwardsSearch)
+    public func replaceOccurrences(of target: String, with replacement: String, options: NSStringCompareOptions = [], range searchRange: NSRange) -> Int {
+        let backwards = options.contains(.backwardsSearch)
         let len = length
         
         precondition(searchRange.length <= len && searchRange.location <= len - searchRange.length, "Search range is out of bounds")
         
-        if options.contains(.RegularExpressionSearch) {
+        if options.contains(.regularExpressionSearch) {
             return _replaceOccurrencesOfRegularExpressionPattern(target, withTemplate:replacement, options:options, range: searchRange)
         }
         
@@ -1395,7 +1395,7 @@
             let numOccurrences = CFArrayGetCount(findResults)
             for cnt in 0..<numOccurrences {
                 let range = UnsafePointer<CFRange>(CFArrayGetValueAtIndex(findResults, backwards ? cnt : numOccurrences - cnt - 1)!)
-                replaceCharactersInRange(NSRange(range.pointee), withString: replacement)
+                replaceCharacters(in: NSRange(range.pointee), with: replacement)
             }
             return numOccurrences
         } else {
diff --git a/Foundation/NSSwiftRuntime.swift b/Foundation/NSSwiftRuntime.swift
index 40cf6a0..a6b5a7a 100644
--- a/Foundation/NSSwiftRuntime.swift
+++ b/Foundation/NSSwiftRuntime.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -360,7 +360,7 @@
 }
 
 extension Array {
-    internal mutating func withUnsafeMutablePointerOrAllocation<R>(_ count: Int, fastpath: UnsafeMutablePointer<Element>? = nil, @noescape body: (UnsafeMutablePointer<Element>) -> R) -> R {
+    internal mutating func withUnsafeMutablePointerOrAllocation<R>(_ count: Int, fastpath: UnsafeMutablePointer<Element>? = nil, body: @noescape (UnsafeMutablePointer<Element>) -> R) -> R {
         if let fastpath = fastpath {
             return body(fastpath)
         } else if self.count > count {
diff --git a/Foundation/NSTask.swift b/Foundation/NSTask.swift
index cc6f559..009781e 100644
--- a/Foundation/NSTask.swift
+++ b/Foundation/NSTask.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSTextCheckingResult.swift b/Foundation/NSTextCheckingResult.swift
index f8380e9..dcb694a 100644
--- a/Foundation/NSTextCheckingResult.swift
+++ b/Foundation/NSTextCheckingResult.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -45,9 +45,9 @@
     
     /* Mandatory properties, used with all types of results. */
     public var resultType: NSTextCheckingType { NSUnimplemented() }
-    public var range: NSRange { return rangeAtIndex(0) }
+    public var range: NSRange { return range(at: 0) }
     /* A result must have at least one range, but may optionally have more (for example, to represent regular expression capture groups).  The range at index 0 always matches the range property.  Additional ranges, if any, will have indexes from 1 to numberOfRanges-1. */
-    public func rangeAtIndex(_ idx: Int) -> NSRange { NSUnimplemented() }
+    public func range(at idx: Int) -> NSRange { NSUnimplemented() }
     public var regularExpression: NSRegularExpression? { return nil }
     public var numberOfRanges: Int { return 1 }
 }
@@ -69,7 +69,7 @@
     }
     
     override var resultType: NSTextCheckingType { return .RegularExpression }
-    override func rangeAtIndex(_ idx: Int) -> NSRange { return _ranges[idx] }
+    override func range(at idx: Int) -> NSRange { return _ranges[idx] }
     override var numberOfRanges: Int { return _ranges.count }
     override var regularExpression: NSRegularExpression? { return _regularExpression }
 }
diff --git a/Foundation/NSThread.swift b/Foundation/NSThread.swift
index 0ccd973..bb72249 100644
--- a/Foundation/NSThread.swift
+++ b/Foundation/NSThread.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSTimeZone.swift b/Foundation/NSTimeZone.swift
index 548aa0a..9935126 100644
--- a/Foundation/NSTimeZone.swift
+++ b/Foundation/NSTimeZone.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSTimer.swift b/Foundation/NSTimer.swift
index 4fd5ef2..2d72378 100644
--- a/Foundation/NSTimer.swift
+++ b/Foundation/NSTimer.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURL.swift b/Foundation/NSURL.swift
index ba11b76..b32d453 100644
--- a/Foundation/NSURL.swift
+++ b/Foundation/NSURL.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLAuthenticationChallenge.swift b/Foundation/NSURLAuthenticationChallenge.swift
index d90f2dc..4cfa63e 100644
--- a/Foundation/NSURLAuthenticationChallenge.swift
+++ b/Foundation/NSURLAuthenticationChallenge.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLCache.swift b/Foundation/NSURLCache.swift
index fdaef5f..92a7189 100644
--- a/Foundation/NSURLCache.swift
+++ b/Foundation/NSURLCache.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLCredential.swift b/Foundation/NSURLCredential.swift
index b5af98b..0965f7e 100644
--- a/Foundation/NSURLCredential.swift
+++ b/Foundation/NSURLCredential.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -31,6 +31,36 @@
     @discussion This class is an immutable object representing an authentication credential.  The actual type of the credential is determined by the constructor called in the categories declared below.
 */
 public class NSURLCredential : NSObject, NSSecureCoding, NSCopying {
+    private var _user : String
+    private var _password : String
+    private var _persistence : NSURLCredentialPersistence
+    
+    /*!
+        @method initWithUser:password:persistence:
+        @abstract Initialize a NSURLCredential with a user and password
+        @param user the username
+        @param password the password
+        @param persistence enum that says to store per session, permanently or not at all
+        @result The initialized NSURLCredential
+     */
+    public init(user: String, password: String, persistence: NSURLCredentialPersistence) {
+        guard persistence != .Permanent && persistence != .Synchronizable else {
+            NSUnimplemented()
+        }
+        _user = user
+        _password = password
+        _persistence = persistence
+        super.init()
+    }
+    
+    /*!
+        @method credentialWithUser:password:persistence:
+        @abstract Create a new NSURLCredential with a user and password
+        @param user the username
+        @param password the password
+        @param persistence enum that says to store per session, permanently or not at all
+        @result The new autoreleased NSURLCredential
+     */
     
     public required init?(coder aDecoder: NSCoder) {
         NSUnimplemented()
@@ -57,36 +87,14 @@
         @abstract Determine whether this credential is or should be stored persistently
         @result A value indicating whether this credential is stored permanently, per session or not at all.
      */
-    public var persistence: NSURLCredentialPersistence { NSUnimplemented() }
-}
-
-extension NSURLCredential {
-    
-    /*!
-        @method initWithUser:password:persistence:
-        @abstract Initialize a NSURLCredential with a user and password
-        @param user the username
-        @param password the password
-        @param persistence enum that says to store per session, permanently or not at all
-        @result The initialized NSURLCredential
-    */
-    public convenience init(user: String, password: String, persistence: NSURLCredentialPersistence) { NSUnimplemented() }
-    
-    /*!
-        @method credentialWithUser:password:persistence:
-        @abstract Create a new NSURLCredential with a user and password
-        @param user the username
-        @param password the password
-        @param persistence enum that says to store per session, permanently or not at all
-        @result The new autoreleased NSURLCredential
-    */
+    public var persistence: NSURLCredentialPersistence { return _persistence }
     
     /*!
         @method user
         @abstract Get the username
         @result The user string
-    */
-    public var user: String? { NSUnimplemented() }
+     */
+    public var user: String? { return _user }
     
     /*!
         @method password
@@ -95,9 +103,9 @@
         @discussion This method might actually attempt to retrieve the
         password from an external store, possible resulting in prompting,
         so do not call it unless needed.
-    */
-    public var password: String? { NSUnimplemented() }
-    
+     */
+    public var password: String? { return _password }
+
     /*!
         @method hasPassword
         @abstract Find out if this credential has a password, without trying to get it
@@ -106,8 +114,11 @@
         external store, the password method may return nil even if this
         method returns YES, since getting the password may fail, or the
         user may refuse access.
-    */
-    public var hasPassword: Bool { NSUnimplemented() }
+     */
+    public var hasPassword: Bool {
+        // Currently no support for SecTrust/SecIdentity, always return true
+        return true
+    }
 }
 
 // TODO: We have no implementation for Security.framework primitive types SecIdentity and SecTrust yet
diff --git a/Foundation/NSURLCredentialStorage.swift b/Foundation/NSURLCredentialStorage.swift
index 9b880f0..ab563c0 100644
--- a/Foundation/NSURLCredentialStorage.swift
+++ b/Foundation/NSURLCredentialStorage.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLError.swift b/Foundation/NSURLError.swift
index e44a083..5ee8f08 100644
--- a/Foundation/NSURLError.swift
+++ b/Foundation/NSURLError.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLProtectionSpace.swift b/Foundation/NSURLProtectionSpace.swift
index 5303b8f..825f414 100644
--- a/Foundation/NSURLProtectionSpace.swift
+++ b/Foundation/NSURLProtectionSpace.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLProtocol.swift b/Foundation/NSURLProtocol.swift
index 4dcd84e..d2f9d06 100644
--- a/Foundation/NSURLProtocol.swift
+++ b/Foundation/NSURLProtocol.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLRequest.swift b/Foundation/NSURLRequest.swift
index 0fa5139..fd42e86 100644
--- a/Foundation/NSURLRequest.swift
+++ b/Foundation/NSURLRequest.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSURLResponse.swift b/Foundation/NSURLResponse.swift
index 0855ddd..e1a7bd1 100644
--- a/Foundation/NSURLResponse.swift
+++ b/Foundation/NSURLResponse.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -322,17 +322,17 @@
     var httpHeaderParts: ValueWithParameters? {
         var type: String?
         var parameters: [ValueWithParameters.Parameter] = []
-        let ws = NSCharacterSet.whitespaceCharacterSet()
+        let ws = NSCharacterSet.whitespaces()
         func append(_ string: String) {
             if type == nil {
                 type = string
             } else {
-                if let r = string.rangeOfString("=") {
-                    let name = string[string.startIndex..<r.startIndex].stringByTrimmingCharactersInSet(ws)
-                    let value = string[r.endIndex..<string.endIndex].stringByTrimmingCharactersInSet(ws)
+                if let r = string.range(of: "=") {
+                    let name = string[string.startIndex..<r.lowerBound].trimmingCharacters(in: ws)
+                    let value = string[r.upperBound..<string.endIndex].trimmingCharacters(in: ws)
                     parameters.append(ValueWithParameters.Parameter(attribute: name, value: value))
                 } else {
-                    let name = string.stringByTrimmingCharactersInSet(ws)
+                    let name = string.trimmingCharacters(in: ws)
                     parameters.append(ValueWithParameters.Parameter(attribute: name, value: nil))
                 }
             }
diff --git a/Foundation/NSURLSession.swift b/Foundation/NSURLSession.swift
index 99a16dc..4836f4e 100644
--- a/Foundation/NSURLSession.swift
+++ b/Foundation/NSURLSession.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSUUID.swift b/Foundation/NSUUID.swift
index 745b4a1..a5ce381 100644
--- a/Foundation/NSUUID.swift
+++ b/Foundation/NSUUID.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSUserDefaults.swift b/Foundation/NSUserDefaults.swift
index 5026d0a..d05f6bf 100644
--- a/Foundation/NSUserDefaults.swift
+++ b/Foundation/NSUserDefaults.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSValue.swift b/Foundation/NSValue.swift
index 9100a7b..706e6c8 100644
--- a/Foundation/NSValue.swift
+++ b/Foundation/NSValue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSXMLDTD.swift b/Foundation/NSXMLDTD.swift
index c4de595..8b00371 100644
--- a/Foundation/NSXMLDTD.swift
+++ b/Foundation/NSXMLDTD.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSXMLDTDNode.swift b/Foundation/NSXMLDTDNode.swift
index 446c4cf..3c2551c 100644
--- a/Foundation/NSXMLDTDNode.swift
+++ b/Foundation/NSXMLDTDNode.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSXMLDocument.swift b/Foundation/NSXMLDocument.swift
index 40c6e77..c58b9dd 100644
--- a/Foundation/NSXMLDocument.swift
+++ b/Foundation/NSXMLDocument.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -61,7 +61,7 @@
         @abstract Returns a document created from either XML or HTML, if the HTMLTidy option is set. Parse errors are returned in <tt>error</tt>.
     */
     public convenience init(XMLString string: String, options mask: Int) throws {
-        guard let data = string._bridgeToObject().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = string._bridgeToObject().data(using: NSUTF8StringEncoding) else {
             // TODO: Throw an error
             fatalError("String: '\(string)' could not be converted to NSData using UTF-8 encoding")
         }
@@ -311,7 +311,7 @@
         let string = XMLStringWithOptions(options)
         // TODO: support encodings other than UTF-8
 
-        return string._bridgeToObject().dataUsingEncoding(NSUTF8StringEncoding) ?? NSData()
+        return string._bridgeToObject().data(using: NSUTF8StringEncoding) ?? NSData()
     }
 
     /*!
diff --git a/Foundation/NSXMLElement.swift b/Foundation/NSXMLElement.swift
index 32ee5cb..17e062b 100644
--- a/Foundation/NSXMLElement.swift
+++ b/Foundation/NSXMLElement.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSXMLNode.swift b/Foundation/NSXMLNode.swift
index cd656ed..b90da38 100644
--- a/Foundation/NSXMLNode.swift
+++ b/Foundation/NSXMLNode.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -480,12 +480,7 @@
         precondition(index >= 0)
         precondition(index < childCount)
 
-        var nodeIndex = startIndex
-        for _ in 0..<index {
-            nodeIndex = nodeIndex.successor()
-        }
-
-        return self[nodeIndex]
+        return self[self.index(startIndex, offsetBy: index)]
     } //primitive
 
     /*!
@@ -885,18 +880,10 @@
 internal protocol _NSXMLNodeCollectionType: Collection { }
 
 extension NSXMLNode: _NSXMLNodeCollectionType {
-    public struct Index: BidirectionalIndex {
+
+    public struct Index: Comparable {
         private let node: _CFXMLNodePtr?
-
-        public func predecessor() -> Index {
-            guard node != nil else { return self }
-            return Index(node: _CFXMLNodeGetPrevSibling(node!))
-        }
-
-        public func successor() -> Index {
-            guard node != nil else { return self }
-            return Index(node: _CFXMLNodeGetNextSibling(node!))
-        }
+        private let offset: Int?
     }
 
     public subscript(index: Index) -> NSXMLNode {
@@ -904,14 +891,34 @@
     }
 
     public var startIndex: Index {
-        return Index(node: _CFXMLNodeGetFirstChild(_xmlNode))
+        let node = _CFXMLNodeGetFirstChild(_xmlNode)
+        return Index(node: node, offset: node.map { _ in 0 })
     }
 
     public var endIndex: Index {
-        return Index(node: nil)
+        return Index(node: nil, offset: nil)
+    }
+
+    public func index(after i: Index) -> Index {
+        precondition(i.node != nil, "can't increment endIndex")
+        let nextNode = _CFXMLNodeGetNextSibling(i.node!)
+        return Index(node: nextNode, offset: nextNode.map { _ in i.offset! + 1 } )
     }
 }
 
 public func ==(lhs: NSXMLNode.Index, rhs: NSXMLNode.Index) -> Bool {
-    return lhs.node == rhs.node
+    return lhs.offset == rhs.offset
+}
+
+public func <(lhs: NSXMLNode.Index, rhs: NSXMLNode.Index) -> Bool {
+    switch (lhs.offset, rhs.offset) {
+    case (nil, nil):
+      return false
+    case (nil, _):
+      return false
+    case (_, nil):
+      return true
+    case (let lhsOffset, let rhsOffset):
+      return lhsOffset < rhsOffset
+    }
 }
diff --git a/Foundation/NSXMLNodeOptions.swift b/Foundation/NSXMLNodeOptions.swift
index 71c8c40..d28f488 100644
--- a/Foundation/NSXMLNodeOptions.swift
+++ b/Foundation/NSXMLNodeOptions.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/NSXMLParser.swift b/Foundation/NSXMLParser.swift
index c2ae9d4..4a8f1b8 100644
--- a/Foundation/NSXMLParser.swift
+++ b/Foundation/NSXMLParser.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/Foundation/String.swift b/Foundation/String.swift
index 4f3a834..863e45e 100644
--- a/Foundation/String.swift
+++ b/Foundation/String.swift
@@ -29,8 +29,8 @@
 @warn_unused_result
 func _toNSRange(_ r: Range<String.Index>) -> NSRange {
     return NSRange(
-        location: r.startIndex._utf16Index,
-                  length: r.endIndex._utf16Index - r.startIndex._utf16Index)
+        location: r.lowerBound._utf16Index,
+                  length: r.upperBound._utf16Index - r.lowerBound._utf16Index)
 }
 
 @warn_unused_result
@@ -64,15 +64,27 @@
 // Random access for String.UTF16View, only when Foundation is
 // imported.  Making this API dependent on Foundation decouples the
 // Swift core from a UTF16 representation.
-extension String.UTF16View.Index : RandomAccessIndex {
+extension String.UTF16View.Index : Strideable {
     /// Construct from an integer offset.
     public init(_ offset: Int) {
         _precondition(offset >= 0, "Negative UTF16 index offset not allowed")
         self.init(_offset: offset)
-        // self._offset = offset
+    }
+
+    @warn_unused_result
+    public func distance(to other: String.UTF16View.Index) -> Int {
+        return other._offset.distance(to: _offset)
+    }
+
+    @warn_unused_result
+    public func advanced(by n: Int) -> String.UTF16View.Index {
+        return String.UTF16View.Index(_offset.advanced(by: n))
     }
 }
 
+extension String.UTF16View : RandomAccessCollection {}
+extension String.UTF16View.Indices : RandomAccessCollection {}
+
 extension String {
     
     //===--- Bridging Helpers -----------------------------------------------===//
@@ -112,7 +124,7 @@
     /// memory referred to by `index`
     func _withOptionalOutParameter<Result>(
         _ index: UnsafeMutablePointer<Index>?,
-        @noescape body: (UnsafeMutablePointer<Int>?) -> Result
+        body: @noescape (UnsafeMutablePointer<Int>?) -> Result
         ) -> Result {
         var utf16Index: Int = 0
         let result = (index != nil) ? body(&utf16Index) : body(nil)
@@ -125,7 +137,7 @@
     /// it into the memory referred to by `range`
     func _withOptionalOutParameter<Result>(
         _ range: UnsafeMutablePointer<Range<Index>>?,
-        @noescape body: (UnsafeMutablePointer<NSRange>?) -> Result
+        body: @noescape (UnsafeMutablePointer<NSRange>?) -> Result
         ) -> Result {
         var nsRange = NSRange(location: 0, length: 0)
         let result = (range != nil) ? body(&nsRange) : body(nil)
@@ -167,7 +179,7 @@
     public static func localizedNameOfStringEncoding(
         _ encoding: NSStringEncoding
         ) -> String {
-        return NSString.localizedNameOfStringEncoding(encoding)
+        return NSString.localizedName(of: encoding)
     }
     
     // + (instancetype)localizedStringWithFormat:(NSString *)format, ...
@@ -255,24 +267,24 @@
     /// `String` can be converted to a given encoding without loss of
     /// information.
     @warn_unused_result
-    public func canBeConvertedToEncoding(_ encoding: NSStringEncoding) -> Bool {
-        return _ns.canBeConvertedToEncoding(encoding)
+    public func canBeConverted(to encoding: NSStringEncoding) -> Bool {
+        return _ns.canBeConverted(to: encoding)
     }
     
     // @property NSString* capitalizedString
     
     /// Produce a string with the first character from each word changed
     /// to the corresponding uppercase value.
-    public var capitalizedString: String {
-        return _ns.capitalizedString as String
+    public var capitalized: String {
+        return _ns.capitalized as String
     }
     
     // @property (readonly, copy) NSString *localizedCapitalizedString NS_AVAILABLE(10_11, 9_0);
     
     /// A capitalized representation of the `String` that is produced
     /// using the current locale.
-    public var localizedCapitalizedString: String {
-        return _ns.localizedCapitalizedString
+    public var localizedCapitalized: String {
+        return _ns.localizedCapitalized
     }
     
     // - (NSString *)capitalizedStringWithLocale:(NSLocale *)locale
@@ -280,8 +292,8 @@
     /// Returns a capitalized representation of the `String`
     /// using the specified locale.
     @warn_unused_result
-    public func capitalizedStringWithLocale(_ locale: NSLocale?) -> String {
-        return _ns.capitalizedStringWithLocale(locale) as String
+    public func capitalized(with locale: NSLocale?) -> String {
+        return _ns.capitalized(with: locale) as String
     }
     
     // - (NSComparisonResult)caseInsensitiveCompare:(NSString *)aString
@@ -307,9 +319,9 @@
     /// given string have in common, starting from the beginning of each
     /// up to the first characters that aren’t equivalent.
     @warn_unused_result
-    public func commonPrefixWithString(
-        _ aString: String, options: NSStringCompareOptions) -> String {
-        return _ns.commonPrefixWithString(aString, options: options)
+    public func commonPrefix(
+        with aString: String, options: NSStringCompareOptions) -> String {
+        return _ns.commonPrefix(with: aString, options: options)
     }
     
     // - (NSComparisonResult)
@@ -340,13 +352,13 @@
         // So let's do that; the switch should compile away anyhow.
         return locale != nil ? _ns.compare(
             aString, options: mask,
-            range: _toNSRange(range ?? self.characters.indices),
+            range: _toNSRange(range ?? self.characters.startIndex..<self.characters.endIndex),
                    locale: locale)
             
             : range != nil ? _ns.compare(
                 aString,
                 options: mask,
-                         range: _toNSRange(range ?? self.characters.indices))
+                         range: _toNSRange(range ?? self.characters.startIndex..<self.characters.endIndex))
                 
             : !mask.isEmpty ? _ns.compare(aString, options: mask)
                 
@@ -402,10 +414,10 @@
     /// Returns an array containing substrings from the `String`
     /// that have been divided by characters in a given set.
     @warn_unused_result
-    public func componentsSeparatedByCharactersInSet(
-        _ separator: NSCharacterSet
+    public func components(
+        separatedBy separator: NSCharacterSet
         ) -> [String] {
-        return _ns.componentsSeparatedByCharactersInSet(separator)
+        return _ns.components(separatedBy: separator)
     }
     
     
@@ -413,8 +425,8 @@
     
     /// Returns an array containing substrings from the `String`
     /// that have been divided by a given separator.
-    public func componentsSeparatedByString(_ separator: String) -> [String] {
-        return _ns.componentsSeparatedByString(separator)
+    public func components(separatedBy separator: String) -> [String] {
+        return _ns.components(separatedBy: separator)
     }
     
     // - (const char *)cStringUsingEncoding:(NSStringEncoding)encoding
@@ -422,10 +434,10 @@
     /// Returns a representation of the `String` as a C string
     /// using a given encoding.
     @warn_unused_result
-    public func cStringUsingEncoding(_ encoding: NSStringEncoding) -> [CChar]? {
+    public func cString(using encoding: NSStringEncoding) -> [CChar]? {
         return withExtendedLifetime(_ns) {
             (s: NSString) -> [CChar]? in
-            _persistCString(s.cStringUsingEncoding(encoding))
+            _persistCString(s.cString(using: encoding))
         }
     }
     
@@ -438,12 +450,12 @@
     /// Returns an `NSData` object containing a representation of
     /// the `String` encoded using a given encoding.
     @warn_unused_result
-    public func dataUsingEncoding(
-        _ encoding: NSStringEncoding,
+    public func data(
+        using encoding: NSStringEncoding,
         allowLossyConversion: Bool = false
         ) -> NSData? {
-        return _ns.dataUsingEncoding(
-            encoding, allowLossyConversion: allowLossyConversion)
+        return _ns.data(
+            using: encoding, allowLossyConversion: allowLossyConversion)
     }
     
     // @property NSString* decomposedStringWithCanonicalMapping;
@@ -476,7 +488,7 @@
     
     /// Enumerates all the lines in a string.
     public func enumerateLines(_ body: (line: String, stop: inout Bool) -> ()) {
-        _ns.enumerateLinesUsingBlock {
+        _ns.enumerateLines {
             (line: String, stop: UnsafeMutablePointer<ObjCBool>)
             in
             var stop_ = false
@@ -500,15 +512,15 @@
     
     /// Enumerates the substrings of the specified type in the
     /// specified range of the string.
-    public func enumerateSubstringsInRange(
-        _ range: Range<Index>,
+    public func enumerateSubstrings(
+        in range: Range<Index>,
         options opts:NSStringEnumerationOptions,
         _ body: (
         substring: String?, substringRange: Range<Index>,
         enclosingRange: Range<Index>, inout Bool
         ) -> ()
         ) {
-        _ns.enumerateSubstringsInRange(_toNSRange(range), options: opts) {
+        _ns.enumerateSubstrings(in: _toNSRange(range), options: opts) {
             var stop_ = false
             
             body(substring: $0,
@@ -585,7 +597,7 @@
               encoding: NSStringEncoding,
               options: NSStringEncodingConversionOptions,
               range: Range<Index>,
-              remainingRange leftover: UnsafeMutablePointer<Range<Index>>
+              remaining leftover: UnsafeMutablePointer<Range<Index>>
         ) -> Bool {
         return _withOptionalOutParameter(leftover) {
             self._ns.getBytes(
@@ -595,7 +607,7 @@
                                        encoding: encoding,
                                                  options: options,
                                                           range: _toNSRange(range),
-                                                                 remainingRange: $0)
+                                                                 remaining: $0)
         }
     }
     
@@ -640,7 +652,7 @@
         _ start: UnsafeMutablePointer<Index>,
         end: UnsafeMutablePointer<Index>,
         contentsEnd: UnsafeMutablePointer<Index>,
-        forRange: Range<Index>
+        for range: Range<Index>
         ) {
         _withOptionalOutParameter(start) {
             start in self._withOptionalOutParameter(end) {
@@ -648,7 +660,7 @@
                     contentsEnd in self._ns.getLineStart(
                         start, end: end,
                         contentsEnd: contentsEnd,
-                                     forRange: _toNSRange(forRange))
+                                     for: _toNSRange(range))
                 }
             }
         }
@@ -666,7 +678,7 @@
         _ start: UnsafeMutablePointer<Index>,
         end: UnsafeMutablePointer<Index>,
         contentsEnd: UnsafeMutablePointer<Index>,
-        forRange: Range<Index>
+        for range: Range<Index>
         ) {
         _withOptionalOutParameter(start) {
             start in self._withOptionalOutParameter(end) {
@@ -674,7 +686,7 @@
                     contentsEnd in self._ns.getParagraphStart(
                         start, end: end,
                         contentsEnd: contentsEnd,
-                                     forRange: _toNSRange(forRange))
+                                     for: _toNSRange(range))
                 }
             }
         }
@@ -949,8 +961,8 @@
     /// Returns the number of bytes required to store the
     /// `String` in a given encoding.
     @warn_unused_result
-    public func lengthOfBytesUsingEncoding(_ encoding: NSStringEncoding) -> Int {
-        return _ns.lengthOfBytesUsingEncoding(encoding)
+    public func lengthOfBytes(using encoding: NSStringEncoding) -> Int {
+        return _ns.lengthOfBytes(using: encoding)
     }
     
     // - (NSRange)lineRangeForRange:(NSRange)aRange
@@ -958,8 +970,8 @@
     /// Returns the range of characters representing the line or lines
     /// containing a given range.
     @warn_unused_result
-    public func lineRangeForRange(_ aRange: Range<Index>) -> Range<Index> {
-        return _range(_ns.lineRangeForRange(_toNSRange(aRange)))
+    public func lineRange(for aRange: Range<Index>) -> Range<Index> {
+        return _range(_ns.lineRange(for: _toNSRange(aRange)))
     }
     
     // - (NSComparisonResult)localizedCaseInsensitiveCompare:(NSString *)aString
@@ -994,8 +1006,8 @@
     
     /// A lowercase version of the string that is produced using the current
     /// locale.
-    public var localizedLowercaseString: String {
-        return _ns.localizedLowercaseString
+    public var localizedLowercase: String {
+        return _ns.localizedLowercase
     }
     
     // - (NSString *)lowercaseStringWithLocale:(NSLocale *)locale
@@ -1004,8 +1016,8 @@
     /// converted to lowercase, taking into account the specified
     /// locale.
     @warn_unused_result
-    public func lowercaseStringWithLocale(_ locale: NSLocale?) -> String {
-        return _ns.lowercaseStringWithLocale(locale)
+    public func lowercased(with locale: NSLocale?) -> String {
+        return _ns.lowercased(with: locale)
     }
     
     // - (NSUInteger)maximumLengthOfBytesUsingEncoding:(NSStringEncoding)enc
@@ -1014,8 +1026,8 @@
     /// `String` in a given encoding.
     @warn_unused_result
     public
-    func maximumLengthOfBytesUsingEncoding(_ encoding: NSStringEncoding) -> Int {
-        return _ns.maximumLengthOfBytesUsingEncoding(encoding)
+    func maximumLengthOfBytes(using encoding: NSStringEncoding) -> Int {
+        return _ns.maximumLengthOfBytes(using: encoding)
     }
     
     // - (NSRange)paragraphRangeForRange:(NSRange)aRange
@@ -1023,8 +1035,8 @@
     /// Returns the range of characters representing the
     /// paragraph or paragraphs containing a given range.
     @warn_unused_result
-    public func paragraphRangeForRange(_ aRange: Range<Index>) -> Range<Index> {
-        return _range(_ns.paragraphRangeForRange(_toNSRange(aRange)))
+    public func paragraphRange(for aRange: Range<Index>) -> Range<Index> {
+        return _range(_ns.paragraphRange(for: _toNSRange(aRange)))
     }
     
     // @property NSArray* pathComponents
@@ -1095,15 +1107,15 @@
     /// character from a given character set found in a given range with
     /// given options.
     @warn_unused_result
-    public func rangeOfCharacterFromSet(
-        _ aSet: NSCharacterSet,
+    public func rangeOfCharacter(
+        from aSet: NSCharacterSet,
         options mask:NSStringCompareOptions = [],
         range aRange: Range<Index>? = nil
         ) -> Range<Index>? {
         return _optionalRange(
-            _ns.rangeOfCharacterFromSet(
-                aSet, options: mask,
-                range: _toNSRange(aRange ?? self.characters.indices)))
+            _ns.rangeOfCharacter(
+                from: aSet, options: mask,
+                range: _toNSRange(aRange ?? self.characters.startIndex..<self.characters.endIndex)))
     }
     
     // - (NSRange)rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)anIndex
@@ -1112,9 +1124,9 @@
     /// character sequence located at a given index.
     @warn_unused_result
     public
-    func rangeOfComposedCharacterSequenceAtIndex(_ anIndex: Index) -> Range<Index> {
+    func rangeOfComposedCharacterSequence(at anIndex: Index) -> Range<Index> {
         return _range(
-            _ns.rangeOfComposedCharacterSequenceAtIndex(anIndex._utf16Index))
+            _ns.rangeOfComposedCharacterSequence(at: anIndex._utf16Index))
     }
     
     // - (NSRange)rangeOfComposedCharacterSequencesForRange:(NSRange)range
@@ -1122,14 +1134,14 @@
     /// Returns the range in the string of the composed character
     /// sequences for a given range.
     @warn_unused_result
-    public func rangeOfComposedCharacterSequencesForRange(
-        _ range: Range<Index>
+    public func rangeOfComposedCharacterSequences(
+        for range: Range<Index>
         ) -> Range<Index> {
         // Theoretically, this will be the identity function.  In practice
         // I think users will be able to observe differences in the input
         // and output ranges due (if nothing else) to locale changes
         return _range(
-            _ns.rangeOfComposedCharacterSequencesForRange(_toNSRange(range)))
+            _ns.rangeOfComposedCharacterSequences(for: _toNSRange(range)))
     }
     
     // - (NSRange)rangeOfString:(NSString *)aString
@@ -1152,23 +1164,23 @@
     /// given string within a given range of the `String`, subject to
     /// given options, using the specified locale, if any.
     @warn_unused_result
-    public func rangeOfString(
-        _ aString: String,
+    public func range(
+        of aString: String,
         options mask: NSStringCompareOptions = [],
         range searchRange: Range<Index>? = nil,
         locale: NSLocale? = nil
         ) -> Range<Index>? {
         return _optionalRange(
-            locale != nil ? _ns.rangeOfString(
-                aString, options: mask,
-                range: _toNSRange(searchRange ?? self.characters.indices),
+            locale != nil ? _ns.range(
+                of: aString, options: mask,
+                range: _toNSRange(searchRange ?? self.characters.startIndex..<self.characters.endIndex),
                 locale: locale
                 )
-                : searchRange != nil ? _ns.rangeOfString(
-                    aString, options: mask, range: _toNSRange(searchRange!)
+                : searchRange != nil ? _ns.range(
+                    of: aString, options: mask, range: _toNSRange(searchRange!)
                     )
-                : !mask.isEmpty ? _ns.rangeOfString(aString, options: mask)
-                : _ns.rangeOfString(aString)
+                : !mask.isEmpty ? _ns.range(of: aString, options: mask)
+                : _ns.range(of: aString)
         )
     }
     
@@ -1182,8 +1194,8 @@
     /// locale-aware, case and diacritic insensitive.  The exact list of search
     /// options applied may change over time.
     @warn_unused_result
-    public func localizedStandardContainsString(_ string: String) -> Bool {
-        return _ns.localizedStandardContainsString(string)
+    public func localizedStandardContains(_ string: String) -> Bool {
+        return _ns.localizedStandardContains(string)
     }
     
     // - (NSRange)localizedStandardRangeOfString:(NSString *)str NS_AVAILABLE(10_11, 9_0);
@@ -1197,8 +1209,8 @@
     /// locale-aware, case and diacritic insensitive.  The exact list of search
     /// options applied may change over time.
     @warn_unused_result
-    public func localizedStandardRangeOfString(_ string: String) -> Range<Index>? {
-        return _optionalRange(_ns.localizedStandardRangeOfString(string))
+    public func localizedStandardRange(of string: String) -> Range<Index>? {
+        return _optionalRange(_ns.localizedStandardRange(of: string))
     }
     
     // @property NSStringEncoding smallestEncoding;
@@ -1263,10 +1275,10 @@
     /// string constructed from a given format string and the following
     /// arguments.
     @warn_unused_result
-    public func stringByAppendingFormat(
+    public func appending(
         _ format: String, _ arguments: CVarArg...
         ) -> String {
-        return _ns.stringByAppendingString(
+        return _ns.appending(
             String(format: format, arguments: arguments))
     }
     
@@ -1296,8 +1308,8 @@
     /// Returns a new string made by appending a given string to
     /// the `String`.
     @warn_unused_result
-    public func stringByAppendingString(_ aString: String) -> String {
-        return _ns.stringByAppendingString(aString)
+    public func appending(_ aString: String) -> String {
+        return _ns.appending(aString)
     }
     
     // @property NSString* stringByDeletingLastPathComponent;
@@ -1332,10 +1344,10 @@
     /// Returns a string with the given character folding options
     /// applied.
     @warn_unused_result
-    public func stringByFoldingWithOptions(
+    public func folding(
         _ options: NSStringCompareOptions, locale: NSLocale?
         ) -> String {
-        return _ns.stringByFoldingWithOptions(options, locale: locale)
+        return _ns.folding(options, locale: locale)
     }
     
     // - (NSString *)stringByPaddingToLength:(NSUInteger)newLength
@@ -1346,11 +1358,11 @@
     /// removing characters from the end, or by appending as many
     /// occurrences as necessary of a given pad string.
     @warn_unused_result
-    public func stringByPaddingToLength(
-        _ newLength: Int, withString padString: String, startingAtIndex padIndex: Int
+    public func padding(
+        toLength newLength: Int, withPad padString: String, startingAt padIndex: Int
         ) -> String {
-        return _ns.stringByPaddingToLength(
-            newLength, withString: padString, startingAtIndex: padIndex)
+        return _ns.padding(
+            toLength: newLength, withPad: padString, startingAt: padIndex)
     }
     
     // @property NSString* stringByRemovingPercentEncoding;
@@ -1369,11 +1381,11 @@
     /// Returns a new string in which the characters in a
     /// specified range of the `String` are replaced by a given string.
     @warn_unused_result
-    public func stringByReplacingCharactersInRange(
-        _ range: Range<Index>, withString replacement: String
+    public func replacingCharacters(
+        in range: Range<Index>, with replacement: String
         ) -> String {
-        return _ns.stringByReplacingCharactersInRange(
-            _toNSRange(range), withString: replacement)
+        return _ns.replacingCharacters(
+            in: _toNSRange(range), with: replacement)
     }
     
     // - (NSString *)
@@ -1390,19 +1402,19 @@
     /// string in a specified range of the `String` are replaced by
     /// another given string.
     @warn_unused_result
-    public func stringByReplacingOccurrencesOfString(
-        _ target: String,
-        withString replacement: String,
+    public func replacingOccurrences(
+        of target: String,
+        with replacement: String,
         options: NSStringCompareOptions = [],
         range searchRange: Range<Index>? = nil
         ) -> String {
         return (searchRange != nil) || (!options.isEmpty)
-            ? _ns.stringByReplacingOccurrencesOfString(
-                target,
-                withString: replacement, options: options,
-                            range: _toNSRange(searchRange ?? self.characters.indices)
+            ? _ns.replacingOccurrences(
+                of: target,
+                with: replacement, options: options,
+                            range: _toNSRange(searchRange ?? self.characters.startIndex..<self.characters.endIndex)
                 )
-            : _ns.stringByReplacingOccurrencesOfString(target, withString: replacement)
+            : _ns.replacingOccurrences(of: target, with: replacement)
     }
     
     // - (NSString *)
@@ -1439,8 +1451,8 @@
     /// Returns a new string made by removing from both ends of
     /// the `String` characters contained in a given character set.
     @warn_unused_result
-    public func stringByTrimmingCharactersInSet(_ set: NSCharacterSet) -> String {
-        return _ns.stringByTrimmingCharactersInSet(set)
+    public func trimmingCharacters(in set: NSCharacterSet) -> String {
+        return _ns.trimmingCharacters(in: set)
     }
     
     // - (NSArray *)stringsByAppendingPaths:(NSArray *)paths
@@ -1456,8 +1468,8 @@
     /// Returns a new string containing the characters of the
     /// `String` from the one at a given index to the end.
     @warn_unused_result
-    public func substringFromIndex(_ index: Index) -> String {
-        return _ns.substringFromIndex(index._utf16Index)
+    public func substring(from index: Index) -> String {
+        return _ns.substring(from: index._utf16Index)
     }
     
     // - (NSString *)substringToIndex:(NSUInteger)anIndex
@@ -1465,8 +1477,8 @@
     /// Returns a new string containing the characters of the
     /// `String` up to, but not including, the one at a given index.
     @warn_unused_result
-    public func substringToIndex(_ index: Index) -> String {
-        return _ns.substringToIndex(index._utf16Index)
+    public func substring(to index: Index) -> String {
+        return _ns.substring(to: index._utf16Index)
     }
     
     // - (NSString *)substringWithRange:(NSRange)aRange
@@ -1474,16 +1486,16 @@
     /// Returns a string object containing the characters of the
     /// `String` that lie within a given range.
     @warn_unused_result
-    public func substringWithRange(_ aRange: Range<Index>) -> String {
-        return _ns.substringWithRange(_toNSRange(aRange))
+    public func substring(with aRange: Range<Index>) -> String {
+        return _ns.substring(with: _toNSRange(aRange))
     }
     
     // @property (readonly, copy) NSString *localizedUppercaseString NS_AVAILABLE(10_11, 9_0);
     
     /// An uppercase version of the string that is produced using the current
     /// locale.
-    public var localizedUppercaseString: String {
-        return _ns.localizedUppercaseString as String
+    public var localizedUppercase: String {
+        return _ns.localizedUppercase as String
     }
     
     // - (NSString *)uppercaseStringWithLocale:(NSLocale *)locale
@@ -1492,8 +1504,8 @@
     /// converted to uppercase, taking into account the specified
     /// locale.
     @warn_unused_result
-    public func uppercaseStringWithLocale(_ locale: NSLocale?) -> String {
-        return _ns.uppercaseStringWithLocale(locale)
+    public func uppercased(with locale: NSLocale?) -> String {
+        return _ns.uppercased(with: locale)
     }
     
     //===--- Omitted due to redundancy with "utf8" property -----------------===//
@@ -1507,12 +1519,12 @@
     
     /// Writes the contents of the `String` to a file at a given
     /// path using a given encoding.
-    public func writeToFile(
-        _ path: String, atomically useAuxiliaryFile:Bool,
+    public func write(
+        toFile path: String, atomically useAuxiliaryFile:Bool,
         encoding enc: NSStringEncoding
         ) throws {
-        try self._ns.writeToFile(
-            path, atomically: useAuxiliaryFile, encoding: enc)
+        try self._ns.write(
+            toFile: path, atomically: useAuxiliaryFile, encoding: enc)
     }
     
     // - (BOOL)
@@ -1523,22 +1535,22 @@
     
     /// Writes the contents of the `String` to the URL specified
     /// by url using the specified encoding.
-    public func writeToURL(
-        _ url: NSURL, atomically useAuxiliaryFile: Bool,
+    public func write(
+        to url: NSURL, atomically useAuxiliaryFile: Bool,
         encoding enc: NSStringEncoding
         ) throws {
-        try self._ns.writeToURL(
-            url, atomically: useAuxiliaryFile, encoding: enc)
+        try self._ns.write(
+            to: url, atomically: useAuxiliaryFile, encoding: enc)
     }
     
     // - (nullable NSString *)stringByApplyingTransform:(NSString *)transform reverse:(BOOL)reverse NS_AVAILABLE(10_11, 9_0);
     
     /// Perform string transliteration.
     @warn_unused_result
-    public func stringByApplyingTransform(
+    public func applyingTransform(
         _ transform: String, reverse: Bool
         ) -> String? {
-        return _ns.stringByApplyingTransform(transform, reverse: reverse)
+        return _ns.applyingTransform(transform, reverse: reverse)
     }
     
     //===--- From the 10.10 release notes; not in public documentation ------===//
@@ -1550,8 +1562,8 @@
     ///
     /// Equivalent to `self.rangeOfString(other) != nil`
     @warn_unused_result
-    public func containsString(_ other: String) -> Bool {
-        let r = self.rangeOfString(other) != nil
+    public func contains(_ other: String) -> Bool {
+        let r = self.range(of: other) != nil
         return r
     }
     
@@ -1569,9 +1581,9 @@
     ///       other, options: .CaseInsensitiveSearch,
     ///       locale: NSLocale.currentLocale()) != nil
     @warn_unused_result
-    public func localizedCaseInsensitiveContainsString(_ other: String) -> Bool {
-        let r = self.rangeOfString(
-            other, options: .CaseInsensitiveSearch, locale: NSLocale.currentLocale()
+    public func localizedCaseInsensitiveContains(_ other: String) -> Bool {
+        let r = self.range(
+            of: other, options: .caseInsensitiveSearch, locale: NSLocale.currentLocale()
             ) != nil
         return r
     }
diff --git a/TestFoundation/TestNSAffineTransform.swift b/TestFoundation/TestNSAffineTransform.swift
index 52d890e..c88aa2f 100644
--- a/TestFoundation/TestNSAffineTransform.swift
+++ b/TestFoundation/TestNSAffineTransform.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSArray.swift b/TestFoundation/TestNSArray.swift
index c90b449..83749be 100644
--- a/TestFoundation/TestNSArray.swift
+++ b/TestFoundation/TestNSArray.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSBundle.swift b/TestFoundation/TestNSBundle.swift
index b09869f..562abd6 100644
--- a/TestFoundation/TestNSBundle.swift
+++ b/TestFoundation/TestNSBundle.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSByteCountFormatter.swift b/TestFoundation/TestNSByteCountFormatter.swift
index f600837..b374662 100644
--- a/TestFoundation/TestNSByteCountFormatter.swift
+++ b/TestFoundation/TestNSByteCountFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSCalendar.swift b/TestFoundation/TestNSCalendar.swift
index c8ce560..3acb68e 100644
--- a/TestFoundation/TestNSCalendar.swift
+++ b/TestFoundation/TestNSCalendar.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -34,7 +34,7 @@
         
         let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)
         calendar?.timeZone = NSTimeZone(name: "UTC")!
-        guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
+        guard let components = calendar?.components([.year, .month, .day], from: date) else {
             XCTFail("Could not get date from the calendar")
             return
         }
@@ -49,7 +49,7 @@
         
         let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierHebrew)
         calendar?.timeZone = NSTimeZone(name: "UTC")!
-        guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
+        guard let components = calendar?.components([.year, .month, .day], from: date) else {
             XCTFail("Could not get date from the Hebrew calendar")
             return
         }
@@ -64,7 +64,7 @@
         
         let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierChinese)
         calendar?.timeZone = NSTimeZone(name: "UTC")!
-        guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
+        guard let components = calendar?.components([.year, .month, .day], from: date) else {
             XCTFail("Could not get date from the Chinese calendar")
             return
         }
diff --git a/TestFoundation/TestNSCharacterSet.swift b/TestFoundation/TestNSCharacterSet.swift
index 459f1dc..496483a 100644
--- a/TestFoundation/TestNSCharacterSet.swift
+++ b/TestFoundation/TestNSCharacterSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -35,29 +35,29 @@
     }
     
     func test_Predefines() {
-        let cset = NSCharacterSet.controlCharacterSet()
+        let cset = NSCharacterSet.controlCharacters()
         
-        XCTAssertTrue(cset === NSCharacterSet.controlCharacterSet(), "predefined charactersets should be singletons")
+        XCTAssertTrue(cset === NSCharacterSet.controlCharacters(), "predefined charactersets should be singletons")
         
         XCTAssertTrue(cset.characterIsMember(unichar(0xFEFF)), "Control set should contain UFEFF")
-        XCTAssertTrue(NSCharacterSet.letterCharacterSet().characterIsMember("a"), "Letter set should contain 'a'")
-        XCTAssertTrue(NSCharacterSet.lowercaseLetterCharacterSet().characterIsMember("a"), "Lowercase Letter set should contain 'a'")
-        XCTAssertTrue(NSCharacterSet.uppercaseLetterCharacterSet().characterIsMember("A"), "Uppercase Letter set should contain 'A'")
-        XCTAssertTrue(NSCharacterSet.uppercaseLetterCharacterSet().characterIsMember(unichar(0x01C5)), "Uppercase Letter set should contain U01C5")
-        XCTAssertTrue(NSCharacterSet.capitalizedLetterCharacterSet().characterIsMember(unichar(0x01C5)), "Uppercase Letter set should contain U01C5")
-        XCTAssertTrue(NSCharacterSet.symbolCharacterSet().characterIsMember(unichar(0x002B)), "Symbol set should contain U002B")
-        XCTAssertTrue(NSCharacterSet.symbolCharacterSet().characterIsMember(unichar(0x20B1)), "Symbol set should contain U20B1")
-        XCTAssertTrue(NSCharacterSet.newlineCharacterSet().characterIsMember(unichar(0x000A)), "Newline set should contain 0x000A")
-        XCTAssertTrue(NSCharacterSet.newlineCharacterSet().characterIsMember(unichar(0x2029)), "Newline set should contain 0x2029")
+        XCTAssertTrue(NSCharacterSet.letters().characterIsMember("a"), "Letter set should contain 'a'")
+        XCTAssertTrue(NSCharacterSet.lowercaseLetters().characterIsMember("a"), "Lowercase Letter set should contain 'a'")
+        XCTAssertTrue(NSCharacterSet.uppercaseLetters().characterIsMember("A"), "Uppercase Letter set should contain 'A'")
+        XCTAssertTrue(NSCharacterSet.uppercaseLetters().characterIsMember(unichar(0x01C5)), "Uppercase Letter set should contain U01C5")
+        XCTAssertTrue(NSCharacterSet.capitalizedLetters().characterIsMember(unichar(0x01C5)), "Uppercase Letter set should contain U01C5")
+        XCTAssertTrue(NSCharacterSet.symbols().characterIsMember(unichar(0x002B)), "Symbol set should contain U002B")
+        XCTAssertTrue(NSCharacterSet.symbols().characterIsMember(unichar(0x20B1)), "Symbol set should contain U20B1")
+        XCTAssertTrue(NSCharacterSet.newlines().characterIsMember(unichar(0x000A)), "Newline set should contain 0x000A")
+        XCTAssertTrue(NSCharacterSet.newlines().characterIsMember(unichar(0x2029)), "Newline set should contain 0x2029")
         
-        let mcset = NSMutableCharacterSet.whitespaceAndNewlineCharacterSet()
-        let cset2 = NSCharacterSet.whitespaceAndNewlineCharacterSet()
+        let mcset = NSMutableCharacterSet.whitespacesAndNewlines()
+        let cset2 = NSCharacterSet.whitespacesAndNewlines()
 
         XCTAssert(mcset.isSupersetOfSet(cset2))
         XCTAssert(cset2.isSupersetOfSet(mcset))
         
-        XCTAssertTrue(NSCharacterSet.whitespaceAndNewlineCharacterSet().isSupersetOfSet(NSCharacterSet.newlineCharacterSet()), "whitespace and newline should be a superset of newline")
-        let data = NSCharacterSet.uppercaseLetterCharacterSet().bitmapRepresentation
+        XCTAssertTrue(NSCharacterSet.whitespacesAndNewlines().isSupersetOfSet(NSCharacterSet.newlines()), "whitespace and newline should be a superset of newline")
+        let data = NSCharacterSet.uppercaseLetters().bitmapRepresentation
         XCTAssertNotNil(data)
     }
     
@@ -84,7 +84,7 @@
     }
     
     func test_String() {
-        let cset = NSCharacterSet(charactersInString: "abcABC")
+        let cset = NSCharacterSet(charactersIn: "abcABC")
         for idx: unichar in 0..<0xFFFF {
             XCTAssertEqual(cset.characterIsMember(idx), (idx >= unichar(unicodeScalarLiteral: "a") && idx <= unichar(unicodeScalarLiteral: "c")) || (idx >= unichar(unicodeScalarLiteral: "A") && idx <= unichar(unicodeScalarLiteral: "C")) ? true : false)
         }
@@ -98,22 +98,22 @@
         let attachmentCharacterUnichar = unichar(0xFFFC)
         let attachmentCharacter = Character(UnicodeScalar(attachmentCharacterUnichar))
 
-        let attachmentCharacterRange = NSRange(Int(attachmentCharacterUnichar)..<Int(attachmentCharacterUnichar.successor()))
+        let attachmentCharacterRange = NSRange(Int(attachmentCharacterUnichar)..<Int(attachmentCharacterUnichar + 1))
 
         let initialSetRange = NSRange(location: 0, length: 0)
         let string = String(attachmentCharacter)
 
         let mcset1 = NSMutableCharacterSet(range: initialSetRange)
-        mcset1.addCharactersInRange(attachmentCharacterRange)
+        mcset1.addCharacters(in: attachmentCharacterRange)
 
         XCTAssertTrue(mcset1.characterIsMember(attachmentCharacterUnichar), "attachmentCharacter should be member of mcset1 after being added")
-        XCTAssertNotNil(string.rangeOfCharacterFromSet(mcset1), "Range of character from mcset1 set should not be nil")
+        XCTAssertNotNil(string.rangeOfCharacter(from: mcset1), "Range of character from mcset1 set should not be nil")
 
         let mcset2 = NSMutableCharacterSet(range: initialSetRange)
-        mcset2.addCharactersInString(string)
+        mcset2.addCharacters(in: string)
 
         XCTAssertTrue(mcset2.characterIsMember(attachmentCharacterUnichar), "attachmentCharacter should be member of mcset2 after being added")
-        XCTAssertNotNil(string.rangeOfCharacterFromSet(mcset2), "Range of character from mcset2 should not be nil")
+        XCTAssertNotNil(string.rangeOfCharacter(from: mcset2), "Range of character from mcset2 should not be nil")
     }
     
     func test_AnnexPlanes() {
@@ -128,4 +128,4 @@
         
     }
 }
-    
\ No newline at end of file
+
diff --git a/TestFoundation/TestNSCompoundPredicate.swift b/TestFoundation/TestNSCompoundPredicate.swift
index 8d3b1c7..b80a830 100644
--- a/TestFoundation/TestNSCompoundPredicate.swift
+++ b/TestFoundation/TestNSCompoundPredicate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSData.swift b/TestFoundation/TestNSData.swift
index cbf7862..7568438 100644
--- a/TestFoundation/TestNSData.swift
+++ b/TestFoundation/TestNSData.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -125,7 +125,7 @@
     func test_initializeWithBase64EncodedDataGetsDecodedData() {
         let plainText = "ARMA virumque cano, Troiae qui primus ab oris\nItaliam, fato profugus, Laviniaque venit"
         let encodedText = "QVJNQSB2aXJ1bXF1ZSBjYW5vLCBUcm9pYWUgcXVpIHByaW11cyBhYiBvcmlzCkl0YWxpYW0sIGZhdG8gcHJvZnVndXMsIExhdmluaWFxdWUgdmVuaXQ="
-        guard let encodedData = encodedText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let encodedData = encodedText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not get UTF-8 data")
             return
         }
@@ -139,11 +139,11 @@
         }
 
         XCTAssertEqual(decodedText, plainText)
-        XCTAssertTrue(decodedData.isEqual(to: plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding)!))    }
+        XCTAssertTrue(decodedData.isEqual(to: plainText.bridge().data(using: NSUTF8StringEncoding)!))    }
     
     func test_initializeWithBase64EncodedDataWithNonBase64CharacterIsNil() {
         let encodedText = "QVJNQSB2aXJ1bXF1ZSBjYW5vLCBUcm9pYWUgcXVpIHBya$W11cyBhYiBvcmlzCkl0YWxpYW0sIGZhdG8gcHJvZnVndXMsIExhdmluaWFxdWUgdmVuaXQ="
-        guard let encodedData = encodedText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let encodedData = encodedText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not get UTF-8 data")
             return
         }
@@ -154,7 +154,7 @@
     func test_initializeWithBase64EncodedDataWithNonBase64CharacterWithOptionToAllowItSkipsCharacter() {
         let plainText = "ARMA virumque cano, Troiae qui primus ab oris\nItaliam, fato profugus, Laviniaque venit"
         let encodedText = "QVJNQSB2aXJ1bXF1ZSBjYW5vLCBUcm9pYWUgcXVpIHBya$W11cyBhYiBvcmlzCkl0YWxpYW0sIGZhdG8gcHJvZnVndXMsIExhdmluaWFxdWUgdmVuaXQ="
-        guard let encodedData = encodedText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let encodedData = encodedText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not get UTF-8 data")
             return
         }
@@ -168,7 +168,7 @@
         }
         
         XCTAssertEqual(decodedText, plainText)
-        XCTAssertTrue(decodedData.isEqual(to: plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding)!))
+        XCTAssertTrue(decodedData.isEqual(to: plainText.bridge().data(using: NSUTF8StringEncoding)!))
     }
     
     func test_initializeWithBase64EncodedStringGetsDecodedData() {
@@ -189,7 +189,7 @@
     func test_base64EncodedDataGetsEncodedText() {
         let plainText = "Constitit, et lacrimans, `Quis iam locus’ inquit `Achate,\nquae regio in terris nostri non plena laboris?`"
         let encodedText = "Q29uc3RpdGl0LCBldCBsYWNyaW1hbnMsIGBRdWlzIGlhbSBsb2N1c+KAmSBpbnF1aXQgYEFjaGF0ZSwKcXVhZSByZWdpbyBpbiB0ZXJyaXMgbm9zdHJpIG5vbiBwbGVuYSBsYWJvcmlzP2A="
-        guard let data = plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = plainText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not encode UTF-8 string")
             return
         }
@@ -204,7 +204,7 @@
     func test_base64EncodedDataWithOptionToInsertLineFeedsContainsLineFeed() {
         let plainText = "Constitit, et lacrimans, `Quis iam locus’ inquit `Achate,\nquae regio in terris nostri non plena laboris?`"
         let encodedText = "Q29uc3RpdGl0LCBldCBsYWNyaW1hbnMsIGBRdWlzIGlhbSBsb2N1c+KAmSBpbnF1\naXQgYEFjaGF0ZSwKcXVhZSByZWdpbyBpbiB0ZXJyaXMgbm9zdHJpIG5vbiBwbGVu\nYSBsYWJvcmlzP2A="
-        guard let data = plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = plainText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not encode UTF-8 string")
             return
         }
@@ -219,7 +219,7 @@
     func test_base64EncodedDataWithOptionToInsertCarriageReturnContainsCarriageReturn() {
         let plainText = "Constitit, et lacrimans, `Quis iam locus’ inquit `Achate,\nquae regio in terris nostri non plena laboris?`"
         let encodedText = "Q29uc3RpdGl0LCBldCBsYWNyaW1hbnMsIGBRdWlzIGlhbSBsb2N1c+KAmSBpbnF1aXQgYEFjaGF0\rZSwKcXVhZSByZWdpbyBpbiB0ZXJyaXMgbm9zdHJpIG5vbiBwbGVuYSBsYWJvcmlzP2A="
-        guard let data = plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = plainText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not encode UTF-8 string")
             return
         }
@@ -234,7 +234,7 @@
     func test_base64EncodedDataWithOptionToInsertCarriageReturnAndLineFeedContainsBoth() {
         let plainText = "Revocate animos, maestumque timorem mittite: forsan et haec olim meminisse iuvabit."
         let encodedText = "UmV2b2NhdGUgYW5pbW9zLCBtYWVzdHVtcXVlIHRpbW9yZW0gbWl0dGl0ZTogZm9yc2FuIGV0IGhh\r\nZWMgb2xpbSBtZW1pbmlzc2UgaXV2YWJpdC4="
-        guard let data = plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = plainText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not encode UTF-8 string")
             return
         }
@@ -249,7 +249,7 @@
     func test_base64EncodedStringGetsEncodedText() {
         let plainText = "Revocate animos, maestumque timorem mittite: forsan et haec olim meminisse iuvabit."
         let encodedText = "UmV2b2NhdGUgYW5pbW9zLCBtYWVzdHVtcXVlIHRpbW9yZW0gbWl0dGl0ZTogZm9yc2FuIGV0IGhhZWMgb2xpbSBtZW1pbmlzc2UgaXV2YWJpdC4="
-        guard let data = plainText.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+        guard let data = plainText.bridge().data(using: NSUTF8StringEncoding) else {
             XCTFail("Could not encode UTF-8 string")
             return
         }
diff --git a/TestFoundation/TestNSDate.swift b/TestFoundation/TestNSDate.swift
index 2c71a26..b1443cf 100644
--- a/TestFoundation/TestNSDate.swift
+++ b/TestFoundation/TestNSDate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSDictionary.swift b/TestFoundation/TestNSDictionary.swift
index 38e0043..98602cf 100644
--- a/TestFoundation/TestNSDictionary.swift
+++ b/TestFoundation/TestNSDictionary.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSFileManager.swift b/TestFoundation/TestNSFileManager.swift
index c8c50c9..dfe9b60 100644
--- a/TestFoundation/TestNSFileManager.swift
+++ b/TestFoundation/TestNSFileManager.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -15,9 +15,9 @@
     import SwiftXCTest
 #endif
 
-class TestNSFileManger : XCTestCase {
+class TestNSFileManager : XCTestCase {
     
-    static var allTests: [(String, TestNSFileManger -> () throws -> Void)] {
+    static var allTests: [(String, TestNSFileManager -> () throws -> Void)] {
         return [
             ("test_createDirectory", test_createDirectory ),
             ("test_createFile", test_createFile ),
@@ -31,7 +31,7 @@
         ]
     }
     
-    func ignoreError(@noescape _ block: () throws -> Void) {
+    func ignoreError(_ block: @noescape () throws -> Void) {
         do { try block() } catch { }
     }
     
diff --git a/TestFoundation/TestNSGeometry.swift b/TestFoundation/TestNSGeometry.swift
index 5d2033b..7b605ac 100644
--- a/TestFoundation/TestNSGeometry.swift
+++ b/TestFoundation/TestNSGeometry.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSHTTPCookie.swift b/TestFoundation/TestNSHTTPCookie.swift
index 792a596..6d934b7 100644
--- a/TestFoundation/TestNSHTTPCookie.swift
+++ b/TestFoundation/TestNSHTTPCookie.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -79,7 +79,7 @@
         ])
         XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.comment)
         XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.commentURL)
-        XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.sessionOnly == true)
+        XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.isSessionOnly == true)
 
         // v0 should never use NSHTTPCookieMaximumAge
         XCTAssert(
@@ -88,13 +88,13 @@
         )
 
         XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.portList)
-        XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.secure == true)
+        XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.isSecure == true)
         XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.version == 0)
     }
     
     func test_RequestHeaderFields() {
         let noCookies: [NSHTTPCookie] = []
-        XCTAssertEqual(NSHTTPCookie.requestHeaderFieldsWithCookies(noCookies)["Cookie"], "")
+        XCTAssertEqual(NSHTTPCookie.requestHeaderFields(with: noCookies)["Cookie"], "")
         
         let basicCookies: [NSHTTPCookie] = [
             NSHTTPCookie(properties: [
@@ -111,7 +111,7 @@
                 ])!,
         ]
         
-        let basicCookieString = NSHTTPCookie.requestHeaderFieldsWithCookies(basicCookies)["Cookie"]
+        let basicCookieString = NSHTTPCookie.requestHeaderFields(with: basicCookies)["Cookie"]
         XCTAssertEqual(basicCookieString, "TestCookie1=testValue1; TestCookie2=testValue2")
     }
-}
\ No newline at end of file
+}
diff --git a/TestFoundation/TestNSIndexPath.swift b/TestFoundation/TestNSIndexPath.swift
index bdde878..b7f276f 100644
--- a/TestFoundation/TestNSIndexPath.swift
+++ b/TestFoundation/TestNSIndexPath.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSIndexSet.swift b/TestFoundation/TestNSIndexSet.swift
index f01bc08..000dae9 100644
--- a/TestFoundation/TestNSIndexSet.swift
+++ b/TestFoundation/TestNSIndexSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSJSONSerialization.swift b/TestFoundation/TestNSJSONSerialization.swift
index 83e87f1..6e9ec86 100644
--- a/TestFoundation/TestNSJSONSerialization.swift
+++ b/TestFoundation/TestNSJSONSerialization.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -47,7 +47,7 @@
     func test_JSONObjectWithData_emptyObject() {
         let subject = NSData(bytes: UnsafePointer<Void>([UInt8]([0x7B, 0x7D])), length: 2)
         
-        let object = try! NSJSONSerialization.JSONObjectWithData(subject, options: []) as? [String:Any]
+        let object = try! NSJSONSerialization.jsonObject(with: subject, options: []) as? [String:Any]
         XCTAssertEqual(object?.count, 0)
     }
     
@@ -75,7 +75,7 @@
         ]
         
         for (description, encoded) in subjects {
-            let result = try? NSJSONSerialization.JSONObjectWithData(NSData(bytes:UnsafePointer<Void>(encoded), length: encoded.count), options: [])
+            let result = try? NSJSONSerialization.jsonObject(with: NSData(bytes:UnsafePointer<Void>(encoded), length: encoded.count), options: [])
             XCTAssertNotNil(result, description)
         }
     }
@@ -93,6 +93,7 @@
             ("test_deserialize_emptyArray", test_deserialize_emptyArray),
             ("test_deserialize_multiStringArray", test_deserialize_multiStringArray),
             ("test_deserialize_unicodeString", test_deserialize_unicodeString),
+            ("test_deserialize_stringWithSpacesAtStart", test_deserialize_stringWithSpacesAtStart),
             
             
             ("test_deserialize_values", test_deserialize_values),
@@ -120,11 +121,11 @@
     func test_deserialize_emptyObject() {
         let subject = "{}"
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            let t = try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            let t = try NSJSONSerialization.jsonObject(with: data, options: [])
             let result = t as? [String: Any]
             XCTAssertEqual(result?.count, 0)
         } catch {
@@ -136,11 +137,11 @@
         let subject = "{ \"hello\": \"world\", \"swift\": \"rocks\" }"
         do {
             for encoding in [NSUTF8StringEncoding, NSUTF16BigEndianStringEncoding] {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String: Any]
+                let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
                 XCTAssertEqual(result?["hello"] as? String, "world")
                 XCTAssertEqual(result?["swift"] as? String, "rocks")
             }
@@ -149,16 +150,33 @@
         }
     }
     
+    func test_deserialize_stringWithSpacesAtStart(){
+        
+        let subject = "{\"title\" : \" hello world!!\" }"
+        do {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else  {
+                XCTFail("Unable to convert string to data")
+                return
+            }
+            let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String : Any]
+            XCTAssertEqual(result?["title"] as? String, " hello world!!")
+        } catch{
+            XCTFail("Error thrown: \(error)")
+        }
+        
+        
+    }
+    
     //MARK: - Array Deserialization
     func test_deserialize_emptyArray() {
         let subject = "[]"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+            let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
             XCTAssertEqual(result?.count, 0)
         } catch {
             XCTFail("Unexpected error: \(error)")
@@ -170,11 +188,11 @@
         
         do {
             for encoding in [NSUTF8StringEncoding, NSUTF16BigEndianStringEncoding] {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+                let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
                 XCTAssertEqual(result?[0] as? String, "hello")
                 XCTAssertEqual(result?[1] as? String, "swift⚡️")
             }
@@ -189,11 +207,11 @@
         
         do {
             for encoding in [NSUTF16LittleEndianStringEncoding, NSUTF16BigEndianStringEncoding, NSUTF32LittleEndianStringEncoding, NSUTF32BigEndianStringEncoding] {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+                let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
                 XCTAssertEqual(result?[0] as? String, "unicode")
                 XCTAssertEqual(result?[1] as? String, "Ģ")
                 XCTAssertEqual(result?[2] as? String, "😢")
@@ -209,11 +227,11 @@
         
         do {
             for encoding in supportedEncodings {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+                let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
                 XCTAssertEqual(result?[0] as? Bool, true)
                 XCTAssertEqual(result?[1] as? Bool, false)
                 XCTAssertEqual(result?[2] as? String, "hello")
@@ -232,13 +250,13 @@
         
         do {
             for encoding in supportedEncodings {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
-                XCTAssertEqual(result?[0] as? Double,     1)
-                XCTAssertEqual(result?[1] as? Double,    -1)
+                let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
+                XCTAssertEqual(result?[0] as? Int,        1)
+                XCTAssertEqual(result?[1] as? Int,       -1)
                 XCTAssertEqual(result?[2] as? Double,   1.3)
                 XCTAssertEqual(result?[3] as? Double,  -1.3)
                 XCTAssertEqual(result?[4] as? Double,  1000)
@@ -253,11 +271,11 @@
     func test_deserialize_simpleEscapeSequences() {
         let subject = "[\"\\\"\", \"\\\\\", \"\\/\", \"\\b\", \"\\f\", \"\\n\", \"\\r\", \"\\t\"]"
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            let res = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+            let res = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
             let result = res?.flatMap { $0 as? String }
             XCTAssertEqual(result?[0], "\"")
             XCTAssertEqual(result?[1], "\\")
@@ -275,11 +293,11 @@
     func test_deserialize_unicodeEscapeSequence() {
         let subject = "[\"\\u2728\"]"
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+            let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
             XCTAssertEqual(result?[0] as? String, "✨")
         } catch {
             XCTFail("Unexpected error: \(error)")
@@ -289,11 +307,11 @@
     func test_deserialize_unicodeSurrogatePairEscapeSequence() {
         let subject = "[\"\\uD834\\udd1E\"]"
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            let result = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [Any]
+            let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]
             XCTAssertEqual(result?[0] as? String, "\u{1D11E}")
         } catch {
             XCTFail("Unexpected error: \(error)")
@@ -305,11 +323,11 @@
         
         do {
             for encoding in supportedEncodings {
-                guard let data = subject.bridge().dataUsingEncoding(encoding) else {
+                guard let data = subject.bridge().data(using: encoding) else {
                     XCTFail("Unable to convert string to data")
                     return
                 }
-                let result = try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? Double
+                let result = try NSJSONSerialization.jsonObject(with: data, options: .AllowFragments) as? Int
                 XCTAssertEqual(result, 3)
             }
         } catch {
@@ -322,11 +340,11 @@
         let subject = "{\"}"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: UnterminatedString")
         } catch {
             // Passing case; the object as unterminated
@@ -337,11 +355,11 @@
         let subject = "{3}"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Missing key for value")
         } catch {
             // Passing case; the key was missing for a value
@@ -352,11 +370,11 @@
         let subject = "{"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Unexpected end of file")
         } catch {
             // Success
@@ -367,11 +385,11 @@
         let subject = "{\"error\":}"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Invalid value")
         } catch {
             // Passing case; the value is invalid
@@ -382,11 +400,11 @@
         let subject = "{\"missing\";}"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Invalid value")
         } catch {
             // passing case the value is invalid
@@ -397,11 +415,11 @@
         let subject = "[,"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Invalid value")
         } catch {
             // Passing case; the element in the array is missing
@@ -412,11 +430,11 @@
         let subject = "[2b4]"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Badly formed array")
         } catch {
             // Passing case; the array is malformed
@@ -427,11 +445,11 @@
         let subject = "[\"\\e\"]"
         
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: [])
+            try NSJSONSerialization.jsonObject(with: data, options: [])
             XCTFail("Expected error: Invalid escape sequence")
         } catch {
             // Passing case; the escape sequence is invalid
@@ -441,11 +459,11 @@
     func test_deserialize_unicodeMissingTrailingSurrogate() {
         let subject = "[\"\\uD834\"]"
         do {
-            guard let data = subject.bridge().dataUsingEncoding(NSUTF8StringEncoding) else {
+            guard let data = subject.bridge().data(using: NSUTF8StringEncoding) else {
                 XCTFail("Unable to convert string to data")
                 return
             }
-            try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String]
+            try NSJSONSerialization.jsonObject(with: data, options: []) as? [String]
             XCTFail("Expected error: Missing Trailing Surrogate")
         } catch {
             // Passing case; the unicode character is malformed
@@ -579,7 +597,7 @@
     }
 
     func trySerialize(_ obj: AnyObject) throws -> String {
-        let data = try NSJSONSerialization.dataWithJSONObject(obj, options: [])
+        let data = try NSJSONSerialization.data(withJSONObject: obj, options: [])
         guard let string = NSString(data: data, encoding: NSUTF8StringEncoding) else {
             XCTFail("Unable to create string")
             return ""
diff --git a/TestFoundation/TestNSKeyedArchiver.swift b/TestFoundation/TestNSKeyedArchiver.swift
index 7c12817..37b6ec3 100644
--- a/TestFoundation/TestNSKeyedArchiver.swift
+++ b/TestFoundation/TestNSKeyedArchiver.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSKeyedUnarchiver.swift b/TestFoundation/TestNSKeyedUnarchiver.swift
index e724106..bfa33c6 100644
--- a/TestFoundation/TestNSKeyedUnarchiver.swift
+++ b/TestFoundation/TestNSKeyedUnarchiver.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSLocale.swift b/TestFoundation/TestNSLocale.swift
index 898b4d8..796f636 100644
--- a/TestFoundation/TestNSLocale.swift
+++ b/TestFoundation/TestNSLocale.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSNotificationCenter.swift b/TestFoundation/TestNSNotificationCenter.swift
index 677cedb..8b9e37c 100755
--- a/TestFoundation/TestNSNotificationCenter.swift
+++ b/TestFoundation/TestNSNotificationCenter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSNotificationQueue.swift b/TestFoundation/TestNSNotificationQueue.swift
index b5b2631..86952f2 100644
--- a/TestFoundation/TestNSNotificationQueue.swift
+++ b/TestFoundation/TestNSNotificationQueue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSNull.swift b/TestFoundation/TestNSNull.swift
index 285dc29..b9cef66 100644
--- a/TestFoundation/TestNSNull.swift
+++ b/TestFoundation/TestNSNull.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSNumber.swift b/TestFoundation/TestNSNumber.swift
index b8287b4..5ba1468 100644
--- a/TestFoundation/TestNSNumber.swift
+++ b/TestFoundation/TestNSNumber.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -33,6 +33,8 @@
             ("test_compareNumberWithFloat", test_compareNumberWithFloat ),
             ("test_compareNumberWithDouble", test_compareNumberWithDouble ),
             ("test_reflection", test_reflection ),
+            ("test_description", test_description ),
+            ("test_descriptionWithLocale", test_descriptionWithLocale ),
         ]
     }
     
@@ -418,4 +420,22 @@
            default: XCTAssert(false, "NSNumber(double:) quicklook is not a Double")
        }
     }
+    
+    func test_description() {
+        let nsnumber: NSNumber = 1000
+        let expectedDesc = "1000"
+        XCTAssertEqual(nsnumber.description, expectedDesc, "expected \(expectedDesc) but received \(nsnumber.description)")
+    }
+    
+    func test_descriptionWithLocale() {
+        let nsnumber: NSNumber = 1000
+        let values : Dictionary = [
+            NSLocale.init(localeIdentifier: "en_GB") : "1,000",
+            NSLocale.init(localeIdentifier: "de_DE") : "1.000",
+        ]
+        for (locale, expectedDesc) in values {
+            let receivedDesc = nsnumber.descriptionWithLocale(locale)
+            XCTAssertEqual(receivedDesc, expectedDesc, "expected \(expectedDesc) but received \(receivedDesc)")
+        }
+    }
 }
diff --git a/TestFoundation/TestNSNumberFormatter.swift b/TestFoundation/TestNSNumberFormatter.swift
index 8a89399..b32a502 100644
--- a/TestFoundation/TestNSNumberFormatter.swift
+++ b/TestFoundation/TestNSNumberFormatter.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSOperationQueue.swift b/TestFoundation/TestNSOperationQueue.swift
new file mode 100644
index 0000000..3ad56c8
--- /dev/null
+++ b/TestFoundation/TestNSOperationQueue.swift
@@ -0,0 +1,36 @@
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+
+
+
+#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
+import Foundation
+import XCTest
+#else
+import SwiftFoundation
+import SwiftXCTest
+#endif
+
+class TestNSOperationQueue : XCTestCase {
+    static var allTests: [(String, TestNSOperationQueue -> () throws -> Void)] {
+        return [
+            ("test_OperationCount", test_OperationCount)
+        ]
+    }
+    
+    func test_OperationCount() {
+        let queue = NSOperationQueue()
+        let op1 = NSBlockOperation(block: { sleep(2) })
+        queue.addOperation(op1)
+        XCTAssertTrue(queue.operationCount == 1)
+        /* uncomment below lines once Dispatch is enabled in Foundation */
+        //queue.waitUntilAllOperationsAreFinished()
+        //XCTAssertTrue(queue.operationCount == 0)
+    }
+}
diff --git a/TestFoundation/TestNSOrderedSet.swift b/TestFoundation/TestNSOrderedSet.swift
index d60f134..1512e32 100644
--- a/TestFoundation/TestNSOrderedSet.swift
+++ b/TestFoundation/TestNSOrderedSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSPipe.swift b/TestFoundation/TestNSPipe.swift
index 660ae97..01b6c6a 100644
--- a/TestFoundation/TestNSPipe.swift
+++ b/TestFoundation/TestNSPipe.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -31,7 +31,7 @@
         let text = "test-pipe"
         
         // First write some data into the pipe
-        let stringAsData = text.bridge().dataUsingEncoding(NSUTF8StringEncoding)
+        let stringAsData = text.bridge().data(using: NSUTF8StringEncoding)
         XCTAssertNotNil(stringAsData)
         aPipe.fileHandleForWriting.writeData(stringAsData!)
         
diff --git a/TestFoundation/TestNSPredicate.swift b/TestFoundation/TestNSPredicate.swift
index 70cdcac..f08a210 100644
--- a/TestFoundation/TestNSPredicate.swift
+++ b/TestFoundation/TestNSPredicate.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -22,6 +22,11 @@
             ("test_BooleanPredicate", test_BooleanPredicate),
             ("test_BlockPredicateWithoutVariableBindings", test_BlockPredicateWithoutVariableBindings),
             ("test_filterNSArray", test_filterNSArray),
+            ("test_filterNSMutableArray", test_filterNSMutableArray),
+            ("test_filterNSSet", test_filterNSSet),
+            ("test_filterNSMutableSet", test_filterNSMutableSet),
+            ("test_filterNSOrderedSet", test_filterNSOrderedSet),
+            ("test_filterNSMutableOrderedSet", test_filterNSMutableOrderedSet),
         ]
     }
 
@@ -43,15 +48,64 @@
         XCTAssertFalse(isNSStringPredicate.evaluateWithObject(NSArray()))
     }
 
+    let lengthLessThanThreePredicate = NSPredicate { (obj, bindings) -> Bool in
+        return (obj as? NSString).map({ $0.length < 3 }) == true
+    }
+
+    let startArray = ["1".bridge(), "12".bridge(), "123".bridge(), "1234".bridge()]
+    let expectedArray = ["1".bridge(), "12".bridge()]
 
     func test_filterNSArray() {
-        let predicate = NSPredicate { (obj, bindings) -> Bool in
-            return (obj as? NSString).map({ $0.length <= 2 }) == true
-        }
+        let filteredArray = startArray.bridge().filteredArrayUsingPredicate(lengthLessThanThreePredicate).bridge()
 
-        let array = NSArray(array: ["1".bridge(), "12".bridge(), "123".bridge(), "1234".bridge()])
-        let filteredArray = array.filteredArrayUsingPredicate(predicate).bridge()
+        XCTAssertEqual(expectedArray.bridge(), filteredArray)
+    }
 
-        XCTAssertEqual(["1".bridge(), "12".bridge()].bridge(), filteredArray)
+    func test_filterNSMutableArray() {
+        let array = startArray.bridge().mutableCopy() as! NSMutableArray
+
+        array.filterUsingPredicate(lengthLessThanThreePredicate)
+
+        XCTAssertEqual(expectedArray.bridge(), array)
+    }
+
+    func test_filterNSSet() {
+        let set = Set(startArray).bridge()
+        let filteredSet = set.filteredSetUsingPredicate(lengthLessThanThreePredicate).bridge()
+
+        XCTAssertEqual(Set(expectedArray).bridge(), filteredSet)
+    }
+
+    func test_filterNSMutableSet() {
+        let set = NSMutableSet(objects: ["1".bridge(), "12".bridge(), "123".bridge(), "1234".bridge()], count: 4)
+        set.filterUsingPredicate(lengthLessThanThreePredicate)
+
+        XCTAssertEqual(Set(expectedArray).bridge(), set)
+    }
+
+    func test_filterNSOrderedSet() {
+        // TODO
+        // This test is temporarily disabled due to a compile crash when calling the initializer of NSOrderedSet with an array
+        /*
+        let orderedSet = NSOrderedSet(array: startArray)
+        let filteredOrderedSet = orderedSet.filteredOrderedSetUsingPredicate(lengthLessThanThreePredicate)
+
+        XCTAssertEqual(NSOrderedSet(array: expectedArray), filteredOrderedSet)
+        */
+    }
+
+    func test_filterNSMutableOrderedSet() {
+        // TODO
+        // This test is temporarily disabled due to a compile crash when calling the initializer of NSOrderedSet with an array
+        /*
+        let orderedSet = NSMutableOrderedSet()
+        orderedSet.addObjectsFromArray(startArray)
+
+        orderedSet.filterUsingPredicate(lengthLessThanThreePredicate)
+
+        let expectedOrderedSet = NSMutableOrderedSet()
+        expectedOrderedSet.addObjectsFromArray(expectedArray)
+        XCTAssertEqual(expectedOrderedSet, orderedSet)
+        */
     }
 }
diff --git a/TestFoundation/TestNSProcessInfo.swift b/TestFoundation/TestNSProcessInfo.swift
index 1664745..53f950a 100644
--- a/TestFoundation/TestNSProcessInfo.swift
+++ b/TestFoundation/TestNSProcessInfo.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -57,7 +57,7 @@
     
     func test_globallyUniqueString() {
         let uuid = NSProcessInfo.processInfo().globallyUniqueString
-        let parts = uuid.bridge().componentsSeparatedByString("-")
+        let parts = uuid.bridge().components(separatedBy: "-")
         XCTAssertEqual(parts.count, 5)
         XCTAssertEqual(parts[0].bridge().length, 8)
         XCTAssertEqual(parts[1].bridge().length, 4)
diff --git a/TestFoundation/TestNSPropertyList.swift b/TestFoundation/TestNSPropertyList.swift
index 12d1808..8412f77 100644
--- a/TestFoundation/TestNSPropertyList.swift
+++ b/TestFoundation/TestNSPropertyList.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSRange.swift b/TestFoundation/TestNSRange.swift
index f187ca2..750e2c3 100644
--- a/TestFoundation/TestNSRange.swift
+++ b/TestFoundation/TestNSRange.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSRegularExpression.swift b/TestFoundation/TestNSRegularExpression.swift
index 6a062cb..5292f65 100644
--- a/TestFoundation/TestNSRegularExpression.swift
+++ b/TestFoundation/TestNSRegularExpression.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -43,8 +43,8 @@
                 XCTAssertTrue((matchResult && match) || (!matchResult && !match), "Case 0 simple regex \(patternString) in \(searchString) match \(matchResult) should be \(match)", file: file, line: line)
             }
             do {
-                let lookingRange = str.rangeOfString(patternString, options: [.RegularExpressionSearch, .AnchoredSearch], range: range, locale: nil)
-                let matchRange = str.rangeOfString(patternString, options: .RegularExpressionSearch, range: range, locale: nil)
+                let lookingRange = str.range(of: patternString, options: [.regularExpressionSearch, .anchoredSearch], range: range, locale: nil)
+                let matchRange = str.range(of: patternString, options: .regularExpressionSearch, range: range, locale: nil)
                 let lookingResult = lookingRange.location == range.location
                 let matchResult = NSEqualRanges(matchRange, range)
                 
@@ -56,8 +56,8 @@
                 let suffixString = " becomes necessary"
                 let searchString2 = "\(prefixString)\(searchString)\(suffixString)".bridge()
                 range.location = prefixString.utf16.count
-                let lookingRange = searchString2.rangeOfString(patternString, options: [.RegularExpressionSearch, .AnchoredSearch], range: range, locale: nil)
-                let matchRange = searchString2.rangeOfString(patternString, options: [.RegularExpressionSearch], range: range, locale: nil)
+                let lookingRange = searchString2.range(of: patternString, options: [.regularExpressionSearch, .anchoredSearch], range: range, locale: nil)
+                let matchRange = searchString2.range(of: patternString, options: [.regularExpressionSearch], range: range, locale: nil)
                 
                 let lookingResult = lookingRange.location == range.location
                 let matchResult = NSEqualRanges(matchRange, range)
@@ -70,8 +70,8 @@
                 let suffixString = " becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary becomes necessary"
                 let searchString2 = "\(prefixString)\(searchString)\(suffixString)".bridge()
                 range.location = prefixString.utf16.count
-                let lookingRange = searchString2.rangeOfString(patternString, options:  [.RegularExpressionSearch, .AnchoredSearch], range: NSMakeRange(range.location, range.length + suffixString.utf16.count), locale: nil)
-                let matchRange = searchString2.rangeOfString(patternString, options: .RegularExpressionSearch, range: NSMakeRange(range.location, range.length + suffixString.utf16.count), locale: nil)
+                let lookingRange = searchString2.range(of: patternString, options:  [.regularExpressionSearch, .anchoredSearch], range: NSMakeRange(range.location, range.length + suffixString.utf16.count), locale: nil)
+                let matchRange = searchString2.range(of: patternString, options: .regularExpressionSearch, range: NSMakeRange(range.location, range.length + suffixString.utf16.count), locale: nil)
                 let lookingResult = lookingRange.location == range.location
                 let matchResult = lookingResult && (matchRange.length >= range.length)
                 
@@ -84,8 +84,8 @@
                 let suffixString = " becomes necessary’"
                 let searchString2 = "\(prefixString)\(searchString)\(suffixString)".bridge()
                 range.location = prefixString.utf16.count
-                let lookingRange = searchString2.rangeOfString(patternString, options: [.RegularExpressionSearch, .AnchoredSearch], range: range, locale: nil)
-                let matchRange = searchString2.rangeOfString(patternString, options: [.RegularExpressionSearch], range: range, locale: nil)
+                let lookingRange = searchString2.range(of: patternString, options: [.regularExpressionSearch, .anchoredSearch], range: range, locale: nil)
+                let matchRange = searchString2.range(of: patternString, options: [.regularExpressionSearch], range: range, locale: nil)
                 
                 let lookingResult = lookingRange.location == range.location
                 let matchResult = NSEqualRanges(matchRange, range)
@@ -221,12 +221,12 @@
             if let first = firstResult where matches.count > 0 {
                 XCTAssertTrue(NSEqualRanges(first.range, firstMatchOverallRange), "Complex regex \(patternString) in \(searchString) match range \(NSStringFromRange(first.range)) should be \(NSStringFromRange(firstMatchOverallRange))", file: file, line: line)
                 if captureCount > 0 {
-                    XCTAssertTrue(NSEqualRanges(first.rangeAtIndex(1), firstMatchFirstCaptureRange), "Complex regex \(patternString) in \(searchString) match range \(first.rangeAtIndex(1)) should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
+                    XCTAssertTrue(NSEqualRanges(first.range(at: 1), firstMatchFirstCaptureRange), "Complex regex \(patternString) in \(searchString) match range \(first.range(at: 1)) should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
                 } else {
                     XCTAssertTrue(NSEqualRanges(firstMatchFirstCaptureRange, NSMakeRange(NSNotFound, 0)), "Complex regex \(patternString) in \(searchString) no captures should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
                 }
                 if captureCount > 1 {
-                    XCTAssertTrue(NSEqualRanges(first.rangeAtIndex(captureCount), firstMatchLastCaptureRange), "Complex regex \(patternString) in \(searchString)  last capture range \(NSStringFromRange(first.rangeAtIndex(captureCount))) should be \(NSStringFromRange(firstMatchLastCaptureRange))", file: file, line: line)
+                    XCTAssertTrue(NSEqualRanges(first.range(at: captureCount), firstMatchLastCaptureRange), "Complex regex \(patternString) in \(searchString)  last capture range \(NSStringFromRange(first.range(at: captureCount))) should be \(NSStringFromRange(firstMatchLastCaptureRange))", file: file, line: line)
                 }
             }
         } catch {
diff --git a/TestFoundation/TestNSRunLoop.swift b/TestFoundation/TestNSRunLoop.swift
index ce21f84..afc9115 100755
--- a/TestFoundation/TestNSRunLoop.swift
+++ b/TestFoundation/TestNSRunLoop.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSScanner.swift b/TestFoundation/TestNSScanner.swift
index eea0c69..bf56d3c 100644
--- a/TestFoundation/TestNSScanner.swift
+++ b/TestFoundation/TestNSScanner.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSSet.swift b/TestFoundation/TestNSSet.swift
index d9b3f05..39da64f 100644
--- a/TestFoundation/TestNSSet.swift
+++ b/TestFoundation/TestNSSet.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSString.swift b/TestFoundation/TestNSString.swift
index 4a33fbe..8dc199c 100644
--- a/TestFoundation/TestNSString.swift
+++ b/TestFoundation/TestNSString.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -110,7 +110,7 @@
         XCTAssertTrue(nonLiteralConversion.length > 4)
         
         let nonLiteral2: NSString = String(4).bridge()
-        let t = nonLiteral2.characterAtIndex(0)
+        let t = nonLiteral2.character(at: 0)
         XCTAssertTrue(t == 52)
         
         let externalString: NSString = String.localizedNameOfStringEncoding(String.defaultCStringEncoding()).bridge()
@@ -187,7 +187,7 @@
     func test_isEqualToStringWithSwiftString() {
         let string: NSString = "literal"
         let swiftString = "literal"
-        XCTAssertTrue(string.isEqualToString(swiftString))
+        XCTAssertTrue(string.isEqual(to: swiftString))
     }
   
     func test_isEqualToObjectWithNSString() {
@@ -212,14 +212,14 @@
         let bytes = mockASCIIStringBytes
         let string = NSString(bytes: bytes, length: bytes.count, encoding: NSASCIIStringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockASCIIString) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockASCIIString) ?? false)
     }
 
     func test_FromUTF8Data() {
         let bytes = mockUTF8StringBytes
         let string = NSString(bytes: bytes, length: bytes.count, encoding: NSUTF8StringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockUTF8String) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockUTF8String) ?? false)
     }
 
     func test_FromMalformedUTF8Data() {
@@ -233,7 +233,7 @@
         let data = NSData(bytes: bytes, length: bytes.count)
         let string = NSString(data: data, encoding: NSASCIIStringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockASCIIString) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockASCIIString) ?? false)
     }
 
     func test_FromUTF8NSData() {
@@ -241,7 +241,7 @@
         let data = NSData(bytes: bytes, length: bytes.count)
         let string = NSString(data: data, encoding: NSUTF8StringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockUTF8String) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockUTF8String) ?? false)
     }
 
     func test_FromMalformedUTF8NSData() {
@@ -255,14 +255,14 @@
         let bytes = mockASCIIStringBytes + [0x00]
         let string = NSString(CString: bytes.map { Int8(bitPattern: $0) }, encoding: NSASCIIStringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockASCIIString) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockASCIIString) ?? false)
     }
 
     func test_FromNullTerminatedCStringInUTF8() {
         let bytes = mockUTF8StringBytes + [0x00]
         let string = NSString(CString: bytes.map { Int8(bitPattern: $0) }, encoding: NSUTF8StringEncoding)
         XCTAssertNotNil(string)
-        XCTAssertTrue(string?.isEqualToString(mockUTF8String) ?? false)
+        XCTAssertTrue(string?.isEqual(to: mockUTF8String) ?? false)
     }
 
     func test_FromMalformedNullTerminatedCStringInUTF8() {
@@ -304,37 +304,37 @@
     }
 
     func test_uppercaseString() {
-        XCTAssertEqual(NSString(stringLiteral: "abcd").uppercaseString, "ABCD")
-        XCTAssertEqual(NSString(stringLiteral: "abcd").uppercaseString, "ABCD") // full-width
-        XCTAssertEqual(NSString(stringLiteral: "абВГ").uppercaseString, "АБВГ")
-        XCTAssertEqual(NSString(stringLiteral: "たちつてと").uppercaseString, "たちつてと")
+        XCTAssertEqual(NSString(stringLiteral: "abcd").uppercased, "ABCD")
+        XCTAssertEqual(NSString(stringLiteral: "abcd").uppercased, "ABCD") // full-width
+        XCTAssertEqual(NSString(stringLiteral: "абВГ").uppercased, "АБВГ")
+        XCTAssertEqual(NSString(stringLiteral: "たちつてと").uppercased, "たちつてと")
 
         // Special casing (see swift/validation-tests/stdlib/NSStringAPI.swift)
-        XCTAssertEqual(NSString(stringLiteral: "\u{0069}").uppercaseStringWithLocale(NSLocale(localeIdentifier: "en")), "\u{0049}")
+        XCTAssertEqual(NSString(stringLiteral: "\u{0069}").uppercased(with: NSLocale(localeIdentifier: "en")), "\u{0049}")
         // Currently fails; likely there are locale loading issues that are preventing this from functioning correctly
-        // XCTAssertEqual(NSString(stringLiteral: "\u{0069}").uppercaseStringWithLocale(NSLocale(localeIdentifier: "tr")), "\u{0130}")
-        XCTAssertEqual(NSString(stringLiteral: "\u{00df}").uppercaseString, "\u{0053}\u{0053}")
-        XCTAssertEqual(NSString(stringLiteral: "\u{fb01}").uppercaseString, "\u{0046}\u{0049}")
+        // XCTAssertEqual(NSString(stringLiteral: "\u{0069}").uppercased(with: NSLocale(localeIdentifier: "tr")), "\u{0130}")
+        XCTAssertEqual(NSString(stringLiteral: "\u{00df}").uppercased, "\u{0053}\u{0053}")
+        XCTAssertEqual(NSString(stringLiteral: "\u{fb01}").uppercased, "\u{0046}\u{0049}")
     }
 
     func test_lowercaseString() {
-        XCTAssertEqual(NSString(stringLiteral: "abCD").lowercaseString, "abcd")
-        XCTAssertEqual(NSString(stringLiteral: "ABCD").lowercaseString, "abcd") // full-width
-        XCTAssertEqual(NSString(stringLiteral: "aБВГ").lowercaseString, "aбвг")
-        XCTAssertEqual(NSString(stringLiteral: "たちつてと").lowercaseString, "たちつてと")
+        XCTAssertEqual(NSString(stringLiteral: "abCD").lowercased, "abcd")
+        XCTAssertEqual(NSString(stringLiteral: "ABCD").lowercased, "abcd") // full-width
+        XCTAssertEqual(NSString(stringLiteral: "aБВГ").lowercased, "aбвг")
+        XCTAssertEqual(NSString(stringLiteral: "たちつてと").lowercased, "たちつてと")
 
         // Special casing (see swift/validation-tests/stdlib/NSStringAPI.swift)
-        XCTAssertEqual(NSString(stringLiteral: "\u{0130}").lowercaseStringWithLocale(NSLocale(localeIdentifier: "en")), "\u{0069}\u{0307}")
+        XCTAssertEqual(NSString(stringLiteral: "\u{0130}").lowercased(with: NSLocale(localeIdentifier: "en")), "\u{0069}\u{0307}")
         // Currently fails; likely there are locale loading issues that are preventing this from functioning correctly
-        // XCTAssertEqual(NSString(stringLiteral: "\u{0130}").lowercaseStringWithLocale(NSLocale(localeIdentifier: "tr")), "\u{0069}")
-        XCTAssertEqual(NSString(stringLiteral: "\u{0049}\u{0307}").lowercaseStringWithLocale(NSLocale(localeIdentifier: "en")), "\u{0069}\u{0307}")
+        // XCTAssertEqual(NSString(stringLiteral: "\u{0130}").lowercased(with: NSLocale(localeIdentifier: "tr")), "\u{0069}")
+        XCTAssertEqual(NSString(stringLiteral: "\u{0049}\u{0307}").lowercased(with: NSLocale(localeIdentifier: "en")), "\u{0069}\u{0307}")
         // Currently fails; likely there are locale loading issues that are preventing this from functioning correctly
         // XCTAssertEqual(NSString(stringLiteral: "\u{0049}\u{0307}").lowercaseStringWithLocale(NSLocale(localeIdentifier: "tr")), "\u{0069}")
     }
 
     func test_capitalizedString() {
-        XCTAssertEqual(NSString(stringLiteral: "foo Foo fOO FOO").capitalizedString, "Foo Foo Foo Foo")
-        XCTAssertEqual(NSString(stringLiteral: "жжж").capitalizedString, "Жжж")
+        XCTAssertEqual(NSString(stringLiteral: "foo Foo fOO FOO").capitalized, "Foo Foo Foo Foo")
+        XCTAssertEqual(NSString(stringLiteral: "жжж").capitalized, "Жжж")
     }
 
     func test_longLongValue() {
@@ -371,12 +371,12 @@
     
     func test_rangeOfCharacterFromSet() {
         let string: NSString = "0Az"
-        let letters = NSCharacterSet.letterCharacterSet()
-        let decimalDigits = NSCharacterSet.decimalDigitCharacterSet()
-        XCTAssertEqual(string.rangeOfCharacterFromSet(letters).location, 1)
-        XCTAssertEqual(string.rangeOfCharacterFromSet(decimalDigits).location, 0)
-        XCTAssertEqual(string.rangeOfCharacterFromSet(letters, options: [.BackwardsSearch]).location, 2)
-        XCTAssertEqual(string.rangeOfCharacterFromSet(letters, options: [], range: NSMakeRange(2, 1)).location, 2)
+        let letters = NSCharacterSet.letters()
+        let decimalDigits = NSCharacterSet.decimalDigits()
+        XCTAssertEqual(string.rangeOfCharacter(from: letters).location, 1)
+        XCTAssertEqual(string.rangeOfCharacter(from: decimalDigits).location, 0)
+        XCTAssertEqual(string.rangeOfCharacter(from: letters, options: [.backwardsSearch]).location, 2)
+        XCTAssertEqual(string.rangeOfCharacter(from: letters, options: [], range: NSMakeRange(2, 1)).location, 2)
     }
     
     func test_CFStringCreateMutableCopy() {
@@ -409,7 +409,7 @@
         let newCFString = CFStringCreateWithBytes(nil, buf, usedLen, CFStringEncoding(kCFStringEncodingUTF16), false)
         let newString = unsafeBitCast(newCFString, to: NSString.self)
         
-        XCTAssertTrue(newString.isEqualToString(testString))
+        XCTAssertTrue(newString.isEqual(to: testString))
     }
     
     func test_completePathIntoString() {
@@ -594,13 +594,13 @@
     }
     
     private func stringsAreCaseInsensitivelyEqual(_ lhs: NSString, _ rhs: NSString) -> Bool {
-    	return lhs.compare(rhs.bridge(), options: .CaseInsensitiveSearch) == .OrderedSame
+    	return lhs.compare(rhs.bridge(), options: .caseInsensitiveSearch) == .OrderedSame
     }
 
     func test_stringByTrimmingCharactersInSet() {
-        let characterSet = NSCharacterSet.whitespaceCharacterSet()
+        let characterSet = NSCharacterSet.whitespaces()
         let string: NSString = " abc   "
-        XCTAssertEqual(string.stringByTrimmingCharactersInSet(characterSet), "abc")
+        XCTAssertEqual(string.trimmingCharacters(in: characterSet), "abc")
     }
     
     func test_initializeWithFormat() {
diff --git a/TestFoundation/TestNSThread.swift b/TestFoundation/TestNSThread.swift
index a91c77b..62c6c53 100644
--- a/TestFoundation/TestNSThread.swift
+++ b/TestFoundation/TestNSThread.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSTimeZone.swift b/TestFoundation/TestNSTimeZone.swift
index 208e3e8..eccc05c 100644
--- a/TestFoundation/TestNSTimeZone.swift
+++ b/TestFoundation/TestNSTimeZone.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSTimer.swift b/TestFoundation/TestNSTimer.swift
index be0e02a..8bec551 100755
--- a/TestFoundation/TestNSTimer.swift
+++ b/TestFoundation/TestNSTimer.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSURL.swift b/TestFoundation/TestNSURL.swift
index 93e89c4..08c3b84 100644
--- a/TestFoundation/TestNSURL.swift
+++ b/TestFoundation/TestNSURL.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSURLCredential.swift b/TestFoundation/TestNSURLCredential.swift
new file mode 100644
index 0000000..55996fd
--- /dev/null
+++ b/TestFoundation/TestNSURLCredential.swift
@@ -0,0 +1,35 @@
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+
+
+#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
+    import Foundation
+    import XCTest
+#else
+    import SwiftFoundation
+    import SwiftXCTest
+#endif
+
+class TestNSURLCredential : XCTestCase {
+    
+    static var allTests: [(String, TestNSURLCredential -> () throws -> Void)] {
+        return [
+                   ("test_construction", test_construction)
+        ]
+    }
+    
+    func test_construction() {
+        let credential = NSURLCredential(user: "swiftUser", password: "swiftPassword", persistence: .ForSession)
+        XCTAssertNotNil(credential)
+        XCTAssertEqual(credential.user, "swiftUser")
+        XCTAssertEqual(credential.password, "swiftPassword")
+        XCTAssertEqual(credential.persistence, NSURLCredentialPersistence.ForSession)
+        XCTAssertEqual(credential.hasPassword, true)
+    }
+}
\ No newline at end of file
diff --git a/TestFoundation/TestNSURLRequest.swift b/TestFoundation/TestNSURLRequest.swift
index bfe301c..0518630 100644
--- a/TestFoundation/TestNSURLRequest.swift
+++ b/TestFoundation/TestNSURLRequest.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -43,7 +43,7 @@
     }
     
     func test_mutableConstruction() {
-        let URL = NSURL(string: "http://swift.org")!
+        let url = NSURL(string: "http://swift.org")!
         let request = NSMutableURLRequest(url: url)
         
         //Confirm initial state matches NSURLRequest responses
diff --git a/TestFoundation/TestNSURLResponse.swift b/TestFoundation/TestNSURLResponse.swift
index 0355115..ff545dd 100644
--- a/TestFoundation/TestNSURLResponse.swift
+++ b/TestFoundation/TestNSURLResponse.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSUUID.swift b/TestFoundation/TestNSUUID.swift
index 1043e3a..e937839 100644
--- a/TestFoundation/TestNSUUID.swift
+++ b/TestFoundation/TestNSUUID.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSUserDefaults.swift b/TestFoundation/TestNSUserDefaults.swift
index 5272c61..a677044 100644
--- a/TestFoundation/TestNSUserDefaults.swift
+++ b/TestFoundation/TestNSUserDefaults.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSValue.swift b/TestFoundation/TestNSValue.swift
index 2936f3c..1bbe421 100644
--- a/TestFoundation/TestNSValue.swift
+++ b/TestFoundation/TestNSValue.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestNSXMLDocument.swift b/TestFoundation/TestNSXMLDocument.swift
index d7ab49b..a44c985 100644
--- a/TestFoundation/TestNSXMLDocument.swift
+++ b/TestFoundation/TestNSXMLDocument.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -317,7 +317,7 @@
         } catch let nsError as NSError {
             XCTAssert(nsError.code == NSXMLParserError.InternalError.rawValue)
             XCTAssert(nsError.domain == NSXMLParserErrorDomain)
-            XCTAssert((nsError.userInfo[NSLocalizedDescriptionKey] as! NSString).containsString("Element img was declared EMPTY this one has content"))
+            XCTAssert((nsError.userInfo[NSLocalizedDescriptionKey] as! NSString).contains("Element img was declared EMPTY this one has content"))
         }
 
         let plistDocString = "<?xml version='1.0' encoding='utf-8'?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> <plist version='1.0'><dict><key>MyKey</key><string>Hello!</string><key>MyBooleanThing</key><true>foobar</true></dict></plist>"
@@ -326,7 +326,7 @@
             try plistDoc.validate()
             XCTFail("Should have thrown!")
         } catch let error as NSError {
-            XCTAssert((error.userInfo[NSLocalizedDescriptionKey] as! NSString).containsString("Element true was declared EMPTY this one has content"))
+            XCTAssert((error.userInfo[NSLocalizedDescriptionKey] as! NSString).contains("Element true was declared EMPTY this one has content"))
         }
     }
 
diff --git a/TestFoundation/TestNSXMLParser.swift b/TestFoundation/TestNSXMLParser.swift
index 9104797..210d176 100644
--- a/TestFoundation/TestNSXMLParser.swift
+++ b/TestFoundation/TestNSXMLParser.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/TestUtils.swift b/TestFoundation/TestUtils.swift
index 60fa091..54686ed 100644
--- a/TestFoundation/TestUtils.swift
+++ b/TestFoundation/TestUtils.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/TestFoundation/main.swift b/TestFoundation/main.swift
index 09a1858..aaee90d 100644
--- a/TestFoundation/main.swift
+++ b/TestFoundation/main.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
@@ -32,7 +32,7 @@
     testCase(TestNSDate.allTests),
     testCase(TestNSDateFormatter.allTests),
     testCase(TestNSDictionary.allTests),
-    testCase(TestNSFileManger.allTests),
+    testCase(TestNSFileManager.allTests),
     testCase(TestNSGeometry.allTests),
     testCase(TestNSHTTPCookie.allTests),
     testCase(TestNSIndexPath.allTests),
@@ -46,6 +46,7 @@
     testCase(TestNSNull.allTests),
     testCase(TestNSNumber.allTests),
     testCase(TestNSNumberFormatter.allTests),
+    testCase(TestNSOperationQueue.allTests),
     testCase(TestNSOrderedSet.allTests),
     testCase(TestNSPipe.allTests),
     testCase(TestNSPredicate.allTests),
@@ -63,6 +64,7 @@
     testCase(TestNSTimeZone.allTests),
     testCase(TestNSURL.allTests),
     testCase(TestNSURLComponents.allTests),
+    testCase(TestNSURLCredential.allTests),
     testCase(TestNSURLRequest.allTests),
     testCase(TestNSURLResponse.allTests),
     testCase(TestNSHTTPURLResponse.allTests),
diff --git a/Tools/plutil/main.swift b/Tools/plutil/main.swift
index 5012130..d10037a 100644
--- a/Tools/plutil/main.swift
+++ b/Tools/plutil/main.swift
@@ -1,6 +1,6 @@
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
 // Licensed under Apache License v2.0 with Runtime Library Exception
 //
 // See http://swift.org/LICENSE.txt for license information
diff --git a/build.py b/build.py
index 1957bc1..7f45227 100644
--- a/build.py
+++ b/build.py
@@ -64,14 +64,18 @@
 		'-I/usr/include/libxml2'
 	]
 
-# Disable until changes are merged into dispatch.
+# Configure use of Dispatch in CoreFoundation and Foundation if libdispatch is being built
 #if "LIBDISPATCH_SOURCE_DIR" in Configuration.current.variables:
-#        foundation.CFLAGS += " "+" ".join([
-#                '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
-#                '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
-#                '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests'  # for include of dispatch/private.h in CF
-#        ])
-
+#	foundation.CFLAGS += " "+" ".join([
+#		'-DDEPLOYMENT_ENABLE_LIBDISPATCH',
+#		'-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
+#		'-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests'  # for include of dispatch/private.h in CF
+#	])
+#	swift_cflags += ([
+#		'-DDEPLOYMENT_ENABLE_LIBDISPATCH',
+#		'-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
+#	])
+#	foundation.LDFLAGS += '-ldispatch -L'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src/.libs '
 
 foundation.SWIFTCFLAGS = " ".join(swift_cflags)