Merge pull request #432 from joewillsher/master

Update protocol compositions to SE-0095 syntax
diff --git a/CoreFoundation/Base.subproj/ForFoundationOnly.h b/CoreFoundation/Base.subproj/ForFoundationOnly.h
index a7ec33e..b020eb2 100644
--- a/CoreFoundation/Base.subproj/ForFoundationOnly.h
+++ b/CoreFoundation/Base.subproj/ForFoundationOnly.h
@@ -564,6 +564,7 @@
 CF_EXPORT CFTypeRef _CFRunLoopGet2(CFRunLoopRef rl);
 
 CF_EXPORT CFIndex _CFStreamInstanceSize(void);
+CF_EXPORT CFReadStreamRef CFReadStreamCreateWithData(CFAllocatorRef alloc, CFDataRef data);
 
 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
     typedef struct {
diff --git a/CoreFoundation/Collections.subproj/CFData.c b/CoreFoundation/Collections.subproj/CFData.c
index 5793926..7d4b60a 100644
--- a/CoreFoundation/Collections.subproj/CFData.c
+++ b/CoreFoundation/Collections.subproj/CFData.c
@@ -331,10 +331,13 @@
 CF_SWIFT_EXPORT void _CFDataInit(CFMutableDataRef memory, CFOptionFlags flags, CFIndex capacity, const uint8_t *bytes, CFIndex length, Boolean noCopy) {
     Boolean isMutable = ((flags & __kCFMutable) != 0);
     Boolean isGrowable = ((flags & __kCFGrowable) != 0);
+    Boolean isDontDeallocate = ((flags & __kCFDontDeallocate) != 0);
     
     __CFDataSetNumBytesUsed(memory, 0);
     __CFDataSetLength(memory, 0);
-    __CFDataSetInfoBits(memory, __kCFDontDeallocate);
+    if(isDontDeallocate) {
+        __CFDataSetInfoBits(memory, __kCFDontDeallocate);
+    }
     
     if (isMutable && isGrowable) {
         __CFDataSetCapacity(memory, __CFDataRoundUpCapacity(1));
diff --git a/CoreFoundation/RunLoop.subproj/CFRunLoop.c b/CoreFoundation/RunLoop.subproj/CFRunLoop.c
index fc5cb66..4cd09f1 100644
--- a/CoreFoundation/RunLoop.subproj/CFRunLoop.c
+++ b/CoreFoundation/RunLoop.subproj/CFRunLoop.c
@@ -61,13 +61,12 @@
 #elif DEPLOYMENT_TARGET_WINDOWS
 #include <process.h>
 DISPATCH_EXPORT HANDLE _dispatch_get_main_queue_handle_4CF(void);
-DISPATCH_EXPORT void _dispatch_main_queue_callback_4CF(void);
+DISPATCH_EXPORT void _dispatch_main_queue_callback_4CF(void*);
 
 #define MACH_PORT_NULL 0
 #define mach_port_name_t HANDLE
 #define mach_port_t HANDLE
 #define _dispatch_get_main_queue_port_4CF _dispatch_get_main_queue_handle_4CF
-#define _dispatch_main_queue_callback_4CF(x) _dispatch_main_queue_callback_4CF()
 
 #define AbsoluteTime LARGE_INTEGER 
 
@@ -78,8 +77,7 @@
 #include <sys/eventfd.h>
 #include <sys/timerfd.h>
 
-#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()
+#define _dispatch_get_main_queue_port_4CF _dispatch_get_main_queue_handle_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 82a1120..8212046 100755
--- a/Foundation.xcodeproj/project.pbxproj
+++ b/Foundation.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		0383A1751D2E558A0052E5D1 /* TestNSStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0383A1741D2E558A0052E5D1 /* TestNSStream.swift */; };
 		294E3C1D1CC5E19300E4F44C /* TestNSAttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 294E3C1C1CC5E19300E4F44C /* TestNSAttributedString.swift */; };
 		2EBE67A51C77BF0E006583D5 /* TestNSDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBE67A31C77BF05006583D5 /* TestNSDateFormatter.swift */; };
 		528776141BF2629700CB0090 /* FoundationErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522C253A1BF16E1600804FC6 /* FoundationErrors.swift */; };
@@ -279,6 +280,7 @@
 		7900433B1CACD33E00ECCBF1 /* TestNSCompoundPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790043391CACD33E00ECCBF1 /* TestNSCompoundPredicate.swift */; };
 		7900433C1CACD33E00ECCBF1 /* TestNSPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7900433A1CACD33E00ECCBF1 /* TestNSPredicate.swift */; };
 		AE35A1861CBAC85E0042DB84 /* SwiftFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = AE35A1851CBAC85E0042DB84 /* SwiftFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		CC5249C01D341D23007CB54D /* TestUnitConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC5249BF1D341D23007CB54D /* TestUnitConverter.swift */; };
 		CE19A88C1C23AA2300B4CB6A /* NSStringTestData.txt in Resources */ = {isa = PBXBuildFile; fileRef = CE19A88B1C23AA2300B4CB6A /* NSStringTestData.txt */; };
 		D31302011C30CEA900295652 /* NSConcreteValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D31302001C30CEA900295652 /* NSConcreteValue.swift */; };
 		D370696E1C394FBF00295652 /* NSKeyedUnarchiver-RangeTest.plist in Resources */ = {isa = PBXBuildFile; fileRef = D370696D1C394FBF00295652 /* NSKeyedUnarchiver-RangeTest.plist */; };
@@ -418,6 +420,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		0383A1741D2E558A0052E5D1 /* TestNSStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSStream.swift; sourceTree = "<group>"; };
 		22B9C1E01C165D7A00DECFF9 /* TestNSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSDate.swift; sourceTree = "<group>"; };
 		294E3C1C1CC5E19300E4F44C /* TestNSAttributedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSAttributedString.swift; sourceTree = "<group>"; };
 		2EBE67A31C77BF05006583D5 /* TestNSDateFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSDateFormatter.swift; sourceTree = "<group>"; };
@@ -681,6 +684,7 @@
 		AE35A1851CBAC85E0042DB84 /* SwiftFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftFoundation.h; sourceTree = "<group>"; };
 		C2A9D75B1C15C08B00993803 /* TestNSUUID.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSUUID.swift; sourceTree = "<group>"; };
 		C93559281C12C49F009FD6A9 /* TestNSAffineTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSAffineTransform.swift; sourceTree = "<group>"; };
+		CC5249BF1D341D23007CB54D /* TestUnitConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUnitConverter.swift; sourceTree = "<group>"; };
 		CE19A88B1C23AA2300B4CB6A /* NSStringTestData.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NSStringTestData.txt; sourceTree = "<group>"; };
 		D3047AEB1C38BC3300295652 /* TestNSValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSValue.swift; sourceTree = "<group>"; };
 		D31302001C30CEA900295652 /* NSConcreteValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSConcreteValue.swift; sourceTree = "<group>"; };
@@ -1272,7 +1276,9 @@
 				D3047AEB1C38BC3300295652 /* TestNSValue.swift */,
 				5B6F17951C48631C00935030 /* TestNSXMLDocument.swift */,
 				5B40F9F11C125187000E72E3 /* TestNSXMLParser.swift */,
+				CC5249BF1D341D23007CB54D /* TestUnitConverter.swift */,
 				5B6F17961C48631C00935030 /* TestUtils.swift */,
+				0383A1741D2E558A0052E5D1 /* TestNSStream.swift */,
 			);
 			name = Tests;
 			sourceTree = "<group>";
@@ -2061,6 +2067,7 @@
 				5B13B3471C582D4C00651CE2 /* TestNSThread.swift in Sources */,
 				5B13B32E1C582D4C00651CE2 /* TestNSFileManager.swift in Sources */,
 				5B13B3381C582D4C00651CE2 /* TestNSNotificationQueue.swift in Sources */,
+				CC5249C01D341D23007CB54D /* TestUnitConverter.swift in Sources */,
 				5B13B3331C582D4C00651CE2 /* TestNSJSONSerialization.swift in Sources */,
 				5B13B33C1C582D4C00651CE2 /* TestNSOrderedSet.swift in Sources */,
 				5B13B34A1C582D4C00651CE2 /* TestNSURL.swift in Sources */,
@@ -2082,6 +2089,7 @@
 				5B13B34E1C582D4C00651CE2 /* TestNSXMLDocument.swift in Sources */,
 				5B13B32B1C582D4C00651CE2 /* TestNSData.swift in Sources */,
 				5B13B34C1C582D4C00651CE2 /* TestNSURLResponse.swift in Sources */,
+				0383A1751D2E558A0052E5D1 /* TestNSStream.swift in Sources */,
 				5B13B3481C582D4C00651CE2 /* TestNSTimer.swift in Sources */,
 				5B13B32D1C582D4C00651CE2 /* TestNSDictionary.swift in Sources */,
 				5B13B3261C582D4C00651CE2 /* TestNSAffineTransform.swift in Sources */,
diff --git a/Foundation/Data.swift b/Foundation/Data.swift
index 73d30e4..3e0b853 100644
--- a/Foundation/Data.swift
+++ b/Foundation/Data.swift
@@ -255,8 +255,8 @@
     ///
     /// Returns nil when the input is not recognized as valid Base-64.
     /// - parameter base64String: The string to parse.
-    /// - parameter options: Encoding options. Default value is `[]`.
-    public init?(base64Encoded base64String: String, options: Data.Base64EncodingOptions = []) {
+    /// - parameter options: Decoding options. Default value is `[]`.
+    public init?(base64Encoded base64String: String, options: Data.Base64DecodingOptions = []) {
         if let d = NSData(base64Encoded: base64String, options: Base64DecodingOptions(rawValue: options.rawValue)) {
             _wrapped = _SwiftNSData(immutableObject: d)
         } else {
diff --git a/Foundation/Date.swift b/Foundation/Date.swift
index d0143bf..86bc4ab 100644
--- a/Foundation/Date.swift
+++ b/Foundation/Date.swift
@@ -49,7 +49,7 @@
         self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate + timeInterval)
     }
     
-    /// Returns an `Date` initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.
+    /// Returns a `Date` initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.
     public init(timeIntervalSinceReferenceDate ti: TimeInterval) {
         _time = ti
     }
@@ -90,7 +90,7 @@
     /**
      The time interval between the date and the current date and time.
      
-     If the date is earlier than the current date and time, the this property’s value is negative.
+     If the date is earlier than the current date and time, this property’s value is negative.
      
      - SeeAlso: `timeIntervalSince(_:)`
      - SeeAlso: `timeIntervalSince1970`
@@ -160,9 +160,9 @@
      
      - Parameter locale: A `Locale` object. If you pass `nil`, `NSDate` formats the date in the same way as the `description` property.
      
-     - Returns: A string representation of the receiver, using the given locale, or if the locale argument is `nil`, in the international format `YYYY-MM-DD HH:MM:SS ±HHMM`, where `±HHMM` represents the time zone offset in hours and minutes from UTC (for example, “`2001-03-24 10:45:32 +0600`”)
+     - Returns: A string representation of the receiver, using the given locale, or if the locale argument is `nil`, in the international format `YYYY-MM-DD HH:MM:SS ±HHMM`, where `±HHMM` represents the time zone offset in hours and minutes from UTC (for example, “`2001-03-24 10:45:32 +0600`”).
      */
-    public func description(with locale : Locale?) -> String {
+    public func description(with locale: Locale?) -> String {
         return NSDate(timeIntervalSinceReferenceDate: _time).descriptionWithLocale(locale)
     }
     
diff --git a/Foundation/FoundationErrors.swift b/Foundation/FoundationErrors.swift
index 6fb24ed..c7aeb1b 100644
--- a/Foundation/FoundationErrors.swift
+++ b/Foundation/FoundationErrors.swift
@@ -7,7 +7,7 @@
 // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
 //
 
-public struct NSCocoaError : RawRepresentable, ErrorProtocol, __BridgedNSError {
+public struct NSCocoaError : RawRepresentable, Swift.Error, __BridgedNSError {
     public let rawValue: Int
     public init(rawValue: Int) {
         self.rawValue = rawValue
diff --git a/Foundation/IndexPath.swift b/Foundation/IndexPath.swift
index 3fb314a..16a8670 100644
--- a/Foundation/IndexPath.swift
+++ b/Foundation/IndexPath.swift
@@ -18,7 +18,7 @@
  
  Each index in an index path represents the index into an array of children from one node in the tree to another, deeper, node.
  */
-public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableCollection, RandomAccessCollection, Comparable, ArrayLiteralConvertible {
+public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableCollection, RandomAccessCollection, Comparable, ExpressibleByArrayLiteral {
     public typealias ReferenceType = NSIndexPath
     public typealias Element = Int
     public typealias Index = Array<Int>.Index
diff --git a/Foundation/IndexSet.swift b/Foundation/IndexSet.swift
index ce98ed8..a5fec10 100644
--- a/Foundation/IndexSet.swift
+++ b/Foundation/IndexSet.swift
@@ -462,7 +462,7 @@
         return _handle.map { $0.contains(in: _toNSRange(range)) }
     }
     
-    /// Returns `true` if `self` contains any of the integers in `indexSet`.
+    /// Returns `true` if `self` contains all of the integers in `indexSet`.
     public func contains(integersIn indexSet: IndexSet) -> Bool {
         return _handle.map { $0.contains(indexSet) }
     }
@@ -523,21 +523,19 @@
         
         while let i = boundaryIterator.next() {
             if !flag {
-                // Starting a range; if the edge is contained or not depends on the xor of this particular value.
-                let startInclusive = self.contains(i) != other.contains(i)
-                start = startInclusive ? i : i + 1
-                flag = true
-            } else {
-                // Ending a range; if the edge is contained or not depends on the xor of this particular value.
-                let endInclusive = self.contains(i) != other.contains(i)
-                let end = endInclusive ? i + 1 : i
-                if start < end {
-                    // Otherwise, we had an empty range
-                    result.insert(integersIn: start..<end)
+                // Start a range if one set contains but not the other.
+                if self.contains(i) != other.contains(i) {
+                    flag = true
+                    start = i
                 }
-                flag = false
+            } else {
+                // End a range if both sets contain or both sets do not contain.
+                if self.contains(i) == other.contains(i) {
+                    flag = false
+                    result.insert(integersIn: start..<i)
+                }
             }
-            // We never have to worry about having flag set to false after exiting this loop because the iterator will always return an even number of results; ranges come in pairs, and we always alternate flag
+            // We never have to worry about having flag set to false after exiting this loop because the last boundary is guaranteed to be past the end of ranges in both index sets
         }
         
         return result
@@ -563,10 +561,10 @@
                     start = i
                 }
             } else {
-                // If both sets contain then end a range.
-                if self.contains(i) && other.contains(i) {
+                // If both sets do not contain then end a range.
+                if !self.contains(i) || !other.contains(i) {
                     flag = false
-                    result.insert(integersIn: start..<(i + 1))
+                    result.insert(integersIn: start..<i)
                 }
             }
         }
@@ -634,7 +632,7 @@
     public func filteredIndexSet(in range : Range<Element>? = nil, includeInteger: @noescape (Element) throws -> Bool) rethrows -> IndexSet {
         let r : NSRange = range != nil ? _toNSRange(range!) : NSMakeRange(0, NSNotFound - 1)
         return try _handle.map {
-            var error : ErrorProtocol? = nil
+            var error : Swift.Error? = nil
             let result = $0.indexes(in: r, options: [], passingTest: { (i, stop) -> Bool in
                 do {
                     let include = try includeInteger(i)
@@ -702,7 +700,7 @@
     }
 }
 
-/// Iterate two index sets on the boundaries of their ranges. This is where all of the interesting stuff happens for exclusive or, intersect, etc.
+/// Iterate two index sets on the boundaries of their ranges. This is where all of the interesting stuff happens for exclusive or, intersect, etc.
 private struct IndexSetBoundaryIterator : IteratorProtocol {
     private typealias Element = IndexSet.Element
     
@@ -710,8 +708,8 @@
     private var i2 : IndexSet.RangeView.Iterator
     private var i1Range : CountableRange<Element>?
     private var i2Range : CountableRange<Element>?
-    private var i1UsedFirst : Bool
-    private var i2UsedFirst : Bool
+    private var i1UsedLower : Bool
+    private var i2UsedLower : Bool
     
     private init(_ is1 : IndexSet, _ is2 : IndexSet) {
         i1 = is1.rangeView().makeIterator()
@@ -720,9 +718,9 @@
         i1Range = i1.next()
         i2Range = i2.next()
         
-        // A sort of cheap iterator on [i1Range.first, i1Range.last]
-        i1UsedFirst = false
-        i2UsedFirst = false
+        // A sort of cheap iterator on [i1Range.lowerBound, i1Range.upperBound]
+        i1UsedLower = false
+        i2UsedLower = false
     }
     
     private mutating func next() -> Element? {
@@ -732,29 +730,34 @@
         
         let nextIn1 : Element
         if let r = i1Range {
-            nextIn1 = i1UsedFirst ? r.last! : r.first!
+            nextIn1 = i1UsedLower ? r.upperBound : r.lowerBound
         } else {
             nextIn1 = Int.max
         }
         
         let nextIn2 : Element
         if let r = i2Range {
-            nextIn2 = i2UsedFirst ? r.last! : r.first!
+            nextIn2 = i2UsedLower ? r.upperBound : r.lowerBound
         } else {
             nextIn2 = Int.max
         }
         
         var result : Element
         if nextIn1 <= nextIn2 {
-            // 1 has the next element, or they are the same. We need to iterate both the value from is1 and is2 in the == case.
+            // 1 has the next element, or they are the same.
             result = nextIn1
-            if i1UsedFirst { i1Range = i1.next() }
-            i1UsedFirst = !i1UsedFirst
+            if i1UsedLower { i1Range = i1.next() }
+            // We need to iterate both the value from is1 and is2 in the == case.
+            if result == nextIn2 {
+                if i2UsedLower { i2Range = i2.next() }
+                i2UsedLower = !i2UsedLower
+            }
+            i1UsedLower = !i1UsedLower
         } else {
             // 2 has the next element
             result = nextIn2
-            if i2UsedFirst { i2Range = i2.next() }
-            i2UsedFirst = !i2UsedFirst
+            if i2UsedLower { i2Range = i2.next() }
+            i2UsedLower = !i2UsedLower
         }
         
         return result
diff --git a/Foundation/NSArray.swift b/Foundation/NSArray.swift
index ec184f5..12636b3 100644
--- a/Foundation/NSArray.swift
+++ b/Foundation/NSArray.swift
@@ -72,13 +72,13 @@
             withUnsafeMutablePointer(&cnt) { (ptr: UnsafeMutablePointer<UInt32>) -> Void in
                 aDecoder.decodeValue(ofObjCType: "i", at: UnsafeMutablePointer<Void>(ptr))
             }
-            let objects = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: Int(cnt))
+            let objects = UnsafeMutablePointer<AnyObject?>.allocate(capacity: Int(cnt))
             for idx in 0..<cnt {
-                objects.advanced(by: Int(idx)).initialize(with: aDecoder.decodeObject())
+                objects.advanced(by: Int(idx)).initialize(to: aDecoder.decodeObject())
             }
             self.init(objects: UnsafePointer<AnyObject?>(objects), count: Int(cnt))
             objects.deinitialize(count: Int(cnt))
-            objects.deallocateCapacity(Int(cnt))
+            objects.deallocate(capacity: Int(cnt))
         } else if aDecoder.dynamicType == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.objects") {
             let objects = aDecoder._decodeArrayOfObjectsForKey("NS.objects")
             self.init(array: objects)
@@ -158,11 +158,11 @@
 //            self.init(objects: ptr.baseAddress, count: array.count)
 //        }
         let cnt = array.count
-        let buffer = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: cnt)
-        buffer.initializeFrom(optionalArray)
+        let buffer = UnsafeMutablePointer<AnyObject?>.allocate(capacity: cnt)
+        buffer.initialize(from: optionalArray)
         self.init(objects: buffer, count: cnt)
         buffer.deinitialize(count: cnt)
-        buffer.deallocateCapacity(cnt)
+        buffer.deallocate(capacity: cnt)
     }
 
     public override func isEqual(_ object: AnyObject?) -> Bool {
@@ -376,14 +376,14 @@
     
     /*@NSCopying*/ public var sortedArrayHint: Data {
         let size = count
-        let buffer = UnsafeMutablePointer<Int32>(allocatingCapacity: size)
+        let buffer = UnsafeMutablePointer<Int32>.allocate(capacity: size)
         for idx in 0..<count {
             let item = object(at: idx) as! NSObject
             let hash = item.hash
             buffer.advanced(by: idx).pointee = Int32(hash).littleEndian
         }
         return Data(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer<UInt8>.self), count: count * sizeof(Int.self), deallocator: .custom({ _ in
-            buffer.deallocateCapacity(size)
+            buffer.deallocate(capacity: size)
             buffer.deinitialize(count: size)
         }))
     }
diff --git a/Foundation/NSCFDictionary.swift b/Foundation/NSCFDictionary.swift
index d3bc84c..ed3ac3f 100644
--- a/Foundation/NSCFDictionary.swift
+++ b/Foundation/NSCFDictionary.swift
@@ -64,7 +64,7 @@
             let cf = dict._cfObject
             count = CFDictionaryGetCount(cf)
             
-            let keys = UnsafeMutablePointer<UnsafePointer<Void>?>(allocatingCapacity: count)            
+            let keys = UnsafeMutablePointer<UnsafePointer<Void>?>.allocate(capacity: count)            
             CFDictionaryGetKeysAndValues(cf, keys, nil)
             
             for idx in 0..<count {
@@ -72,7 +72,7 @@
                 keyArray.append(key)
             }
             keys.deinitialize()
-            keys.deallocateCapacity(count)
+            keys.deallocate(capacity: count)
         }
     }
 
diff --git a/Foundation/NSCFString.swift b/Foundation/NSCFString.swift
index 58ab1d6..4eba1d4 100644
--- a/Foundation/NSCFString.swift
+++ b/Foundation/NSCFString.swift
@@ -135,7 +135,7 @@
             for idx in 0..<range.length {
                 let characterIndex = encodingView.index(start, offsetBy: idx + range.location)
                 let character = encodingView[characterIndex]
-                buffer.advanced(by: idx).initialize(with: character)
+                buffer.advanced(by: idx).initialize(to: character)
             }
         }
         usedBufLen?.pointee = range.length
@@ -149,8 +149,8 @@
                 let character = encodingView[start.advanced(by: idx + range.location)]
                 let byte0 = UInt8(character & 0x00ff)
                 let byte1 = UInt8((character >> 8) & 0x00ff)
-                buffer.advanced(by: idx * 2).initialize(with: byte0)
-                buffer.advanced(by: (idx * 2) + 1).initialize(with: byte1)
+                buffer.advanced(by: idx * 2).initialize(to: byte0)
+                buffer.advanced(by: (idx * 2) + 1).initialize(to: byte1)
             }
         }
         // Every character was 2 bytes
diff --git a/Foundation/NSCalendar.swift b/Foundation/NSCalendar.swift
index 8819a43..674e923 100644
--- a/Foundation/NSCalendar.swift
+++ b/Foundation/NSCalendar.swift
@@ -167,11 +167,17 @@
     }
     
     public func copy(with zone: NSZone? = nil) -> AnyObject {
-        NSUnimplemented()
+        let copy = Calendar(calendarIdentifier: calendarIdentifier)!
+        copy.locale = locale
+        copy.timeZone = timeZone
+        copy.firstWeekday = firstWeekday
+        copy.minimumDaysInFirstWeek = minimumDaysInFirstWeek
+        copy._startDate = _startDate
+        return copy
     }
     
 
-    public class func currentCalendar() -> Calendar {
+    public class var current: Calendar {
         return CFCalendarCopyCurrent()._nsObject
     }
     
diff --git a/Foundation/NSCoder.swift b/Foundation/NSCoder.swift
index 14b6f26..901a69a 100644
--- a/Foundation/NSCoder.swift
+++ b/Foundation/NSCoder.swift
@@ -22,7 +22,7 @@
     deinit {
         for buffer in _pendingBuffers {
             buffer.0.deinitialize()
-            buffer.0.deallocateCapacity(buffer.1)
+            buffer.0.deallocate(capacity: buffer.1)
         }
     }
     
@@ -159,7 +159,7 @@
             decodeValue(ofObjCType: "I", at: unsafeBitCast(ptr, to: UnsafeMutablePointer<Void>.self))
         }
         // we cannot autorelease here so instead the pending buffers will manage the lifespan of the returned data... this is wasteful but good enough...
-        let result = UnsafeMutablePointer<Void>(allocatingCapacity: Int(length))
+        let result = UnsafeMutablePointer<Void>.allocate(capacity: Int(length))
         decodeValue(ofObjCType: "c", at: result)
         lengthp.pointee = Int(length)
         _pendingBuffers.append((result, Int(length)))
diff --git a/Foundation/NSCompoundPredicate.swift b/Foundation/NSCompoundPredicate.swift
index 6211ab7..6682a2a 100644
--- a/Foundation/NSCompoundPredicate.swift
+++ b/Foundation/NSCompoundPredicate.swift
@@ -48,11 +48,11 @@
     override public func evaluate(with object: AnyObject?, substitutionVariables bindings: [String : AnyObject]?) -> Bool {
         switch compoundPredicateType {
         case .and:
-            return subpredicates.reduce(true, combine: {
+            return subpredicates.reduce(true, {
                 $0 && $1.evaluate(with: object, substitutionVariables: bindings)
             })
         case .or:
-            return subpredicates.reduce(false, combine: {
+            return subpredicates.reduce(false, {
                 $0 || $1.evaluate(with: object, substitutionVariables: bindings)
             })
         case .not:
diff --git a/Foundation/NSConcreteValue.swift b/Foundation/NSConcreteValue.swift
index b3737d7..55bde6e 100644
--- a/Foundation/NSConcreteValue.swift
+++ b/Foundation/NSConcreteValue.swift
@@ -91,17 +91,17 @@
 
         self._typeInfo = typeInfo!
 
-        self._storage = UnsafeMutablePointer<UInt8>(allocatingCapacity: self._typeInfo.size)
-        self._storage.initializeFrom(unsafeBitCast(value, to: UnsafeMutablePointer<UInt8>.self), count: self._typeInfo.size)
+        self._storage = UnsafeMutablePointer<UInt8>.allocate(capacity: self._typeInfo.size)
+        self._storage.initialize(from: unsafeBitCast(value, to: UnsafeMutablePointer<UInt8>.self), count: self._typeInfo.size)
     }
 
     deinit {
         self._storage.deinitialize(count: self._size)
-        self._storage.deallocateCapacity(self._size)
+        self._storage.deallocate(capacity: self._size)
     }
     
     override func getValue(_ value: UnsafeMutablePointer<Void>) {
-        UnsafeMutablePointer<UInt8>(value).moveInitializeFrom(unsafeBitCast(self._storage, to: UnsafeMutablePointer<UInt8>.self), count: self._size)
+        UnsafeMutablePointer<UInt8>(value).moveInitialize(from: unsafeBitCast(self._storage, to: UnsafeMutablePointer<UInt8>.self), count: self._size)
     }
     
     override var objCType : UnsafePointer<Int8> {
diff --git a/Foundation/NSData.swift b/Foundation/NSData.swift
index ab09070..ac6a210 100644
--- a/Foundation/NSData.swift
+++ b/Foundation/NSData.swift
@@ -553,7 +553,7 @@
     }
     
     internal func enumerateByteRangesUsingBlockRethrows(_ block: @noescape (UnsafePointer<Void>, NSRange, UnsafeMutablePointer<Bool>) throws -> Void) throws {
-        var err : ErrorProtocol? = nil
+        var err : Swift.Error? = nil
         self.enumerateBytes() { (buf, range, stop) -> Void in
             do {
                 try block(buf, range, stop)
@@ -936,9 +936,7 @@
     }
     
     public convenience init?(length: Int) {
-        let memory = malloc(length)
-        self.init(bytes: memory, length: length, copy: false) { buffer, amount in
-            free(buffer)
-        }
+        self.init(bytes: nil, length: 0)
+        self.length = length
     }
 }
diff --git a/Foundation/NSDateFormatter.swift b/Foundation/NSDateFormatter.swift
index 7e8d1cf..13fcf57 100644
--- a/Foundation/NSDateFormatter.swift
+++ b/Foundation/NSDateFormatter.swift
@@ -140,7 +140,7 @@
 
     public var timeStyle: Style = .noStyle { willSet { _dateFormat = nil; _reset() } }
 
-    /*@NSCopying*/ public var locale: Locale! = .currentLocale() { willSet { _reset() } }
+    /*@NSCopying*/ public var locale: Locale! = .current { willSet { _reset() } }
 
     public var generatesCalendarDates = false { willSet { _reset() } }
 
diff --git a/Foundation/NSDictionary.swift b/Foundation/NSDictionary.swift
index 2be25d3..af53799 100644
--- a/Foundation/NSDictionary.swift
+++ b/Foundation/NSDictionary.swift
@@ -12,16 +12,16 @@
 
 extension Dictionary : _ObjectTypeBridgeable {
     public func _bridgeToObject() -> NSDictionary {
-        let keyBuffer = UnsafeMutablePointer<NSObject>(allocatingCapacity: count)
-        let valueBuffer = UnsafeMutablePointer<AnyObject>(allocatingCapacity: count)
+        let keyBuffer = UnsafeMutablePointer<NSObject>.allocate(capacity: count)
+        let valueBuffer = UnsafeMutablePointer<AnyObject>.allocate(capacity: count)
         
         var idx = 0
         
         self.forEach {
             let key = _NSObjectRepresentableBridge($0.0)
             let value = _NSObjectRepresentableBridge($0.1)
-            keyBuffer.advanced(by: idx).initialize(with: key)
-            valueBuffer.advanced(by: idx).initialize(with: value)
+            keyBuffer.advanced(by: idx).initialize(to: key)
+            valueBuffer.advanced(by: idx).initialize(to: value)
             idx += 1
         }
         
@@ -29,8 +29,8 @@
         
         keyBuffer.deinitialize(count: count)
         valueBuffer.deinitialize(count: count)
-        keyBuffer.deallocateCapacity(count)
-        valueBuffer.deallocateCapacity(count)
+        keyBuffer.deallocate(capacity: count)
+        valueBuffer.deallocate(capacity: count)
 
         return dict
     }
@@ -52,8 +52,8 @@
             let cf = x._cfObject
             let cnt = CFDictionaryGetCount(cf)
 
-            let keys = UnsafeMutablePointer<UnsafePointer<Void>?>(allocatingCapacity: cnt)
-            let values = UnsafeMutablePointer<UnsafePointer<Void>?>(allocatingCapacity: cnt)
+            let keys = UnsafeMutablePointer<UnsafePointer<Void>?>.allocate(capacity: cnt)
+            let values = UnsafeMutablePointer<UnsafePointer<Void>?>.allocate(capacity: cnt)
             
             CFDictionaryGetKeysAndValues(cf, keys, values)
             
@@ -68,8 +68,8 @@
             }
             keys.deinitialize(count: cnt)
             values.deinitialize(count: cnt)
-            keys.deallocateCapacity(cnt)
-            values.deallocateCapacity(cnt)
+            keys.deallocate(capacity: cnt)
+            values.deallocate(capacity: cnt)
         }
         if !failedConversion {
             result = dict
@@ -128,17 +128,17 @@
             withUnsafeMutablePointer(&cnt) { (ptr: UnsafeMutablePointer<UInt32>) -> Void in
                 aDecoder.decodeValue(ofObjCType: "i", at: UnsafeMutablePointer<Void>(ptr))
             }
-            let keys = UnsafeMutablePointer<NSObject>(allocatingCapacity: Int(cnt))
-            let objects = UnsafeMutablePointer<AnyObject>(allocatingCapacity: Int(cnt))
+            let keys = UnsafeMutablePointer<NSObject>.allocate(capacity: Int(cnt))
+            let objects = UnsafeMutablePointer<AnyObject>.allocate(capacity: Int(cnt))
             for idx in 0..<cnt {
-                keys.advanced(by: Int(idx)).initialize(with: aDecoder.decodeObject()! as! NSObject)
-                objects.advanced(by: Int(idx)).initialize(with: aDecoder.decodeObject()!)
+                keys.advanced(by: Int(idx)).initialize(to: aDecoder.decodeObject()! as! NSObject)
+                objects.advanced(by: Int(idx)).initialize(to: aDecoder.decodeObject()!)
             }
             self.init(objects: UnsafePointer<AnyObject>(objects), forKeys: UnsafePointer<NSObject>(keys), count: Int(cnt))
             keys.deinitialize(count: Int(cnt))
-            keys.deallocateCapacity(Int(cnt))
+            keys.deallocate(capacity: Int(cnt))
             objects.deinitialize(count: Int(cnt))
-            objects.deallocateCapacity(Int(cnt))
+            objects.deallocate(capacity: Int(cnt))
             
         } else if aDecoder.dynamicType == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.objects") {
             let keys = aDecoder._decodeArrayOfObjectsForKey("NS.keys").map() { return $0 as! NSObject }
@@ -226,18 +226,18 @@
 //    }
     
     public convenience init(objects: [AnyObject], forKeys keys: [NSObject]) {
-        let keyBuffer = UnsafeMutablePointer<NSObject>(allocatingCapacity: keys.count)
-        keyBuffer.initializeFrom(keys)
+        let keyBuffer = UnsafeMutablePointer<NSObject>.allocate(capacity: keys.count)
+        keyBuffer.initialize(from: keys)
 
-        let valueBuffer = UnsafeMutablePointer<AnyObject>(allocatingCapacity: objects.count)
-        valueBuffer.initializeFrom(objects)
+        let valueBuffer = UnsafeMutablePointer<AnyObject>.allocate(capacity: objects.count)
+        valueBuffer.initialize(from: objects)
 
         self.init(objects: valueBuffer, forKeys:keyBuffer, count: keys.count)
         
         keyBuffer.deinitialize(count: keys.count)
         valueBuffer.deinitialize(count: objects.count)
-        keyBuffer.deallocateCapacity(keys.count)
-        valueBuffer.deallocateCapacity(objects.count)
+        keyBuffer.deallocate(capacity: keys.count)
+        valueBuffer.deallocate(capacity: objects.count)
     }
 
     public override func isEqual(_ object: AnyObject?) -> Bool {
@@ -679,7 +679,7 @@
     public convenience init(sharedKeySet keyset: AnyObject) { NSUnimplemented() }
 }
 
-extension NSDictionary : DictionaryLiteralConvertible { }
+extension NSDictionary : ExpressibleByDictionaryLiteral { }
 
 extension Dictionary : Bridgeable {
     public func bridge() -> NSDictionary { return _nsObject }
diff --git a/Foundation/NSError.swift b/Foundation/NSError.swift
index f1bd733..20e8410 100644
--- a/Foundation/NSError.swift
+++ b/Foundation/NSError.swift
@@ -165,7 +165,7 @@
     }
 }
 
-extension NSError : ErrorProtocol { }
+extension NSError : Swift.Error { }
 
 extension NSError : _CFBridgable { }
 extension CFError : _NSBridgable {
@@ -184,11 +184,11 @@
 }
 
 
-public protocol _ObjectTypeBridgeableErrorType : ErrorProtocol {
+public protocol _ObjectTypeBridgeableErrorType : Swift.Error {
     init?(_bridgedNSError: NSError)
 }
 
-public protocol __BridgedNSError : RawRepresentable, ErrorProtocol {
+public protocol __BridgedNSError : RawRepresentable, Swift.Error {
     static var __NSErrorDomain: String { get }
 }
 
diff --git a/Foundation/NSFileHandle.swift b/Foundation/NSFileHandle.swift
index cb4191e..cd58bda 100644
--- a/Foundation/NSFileHandle.swift
+++ b/Foundation/NSFileHandle.swift
@@ -193,25 +193,28 @@
     internal static var _stdinFileHandle: FileHandle = {
         return FileHandle(fileDescriptor: STDIN_FILENO, closeOnDealloc: false)
     }()
-    public class func fileHandleWithStandardInput() -> FileHandle {
+
+    public class func standardInput() -> FileHandle {
         return _stdinFileHandle
     }
     
     internal static var _stdoutFileHandle: FileHandle = {
         return FileHandle(fileDescriptor: STDOUT_FILENO, closeOnDealloc: false)
     }()
-    public class func fileHandleWithStandardOutput() -> FileHandle {
+
+    public class func standardOutput() -> FileHandle {
         return _stdoutFileHandle
     }
     
     internal static var _stderrFileHandle: FileHandle = {
         return FileHandle(fileDescriptor: STDERR_FILENO, closeOnDealloc: false)
     }()
-    public class func fileHandleWithStandardError() -> FileHandle {
+    
+    public class func standardError() -> FileHandle {
         return _stderrFileHandle
     }
     
-    public class func fileHandleWithNullDevice() -> FileHandle {
+    public class func nullDevice() -> FileHandle {
         NSUnimplemented()
     }
     
@@ -239,17 +242,17 @@
         }
     }
     
-    public convenience init(forReadingFromURL url: URL) throws {
+    public convenience init(forReadingFrom url: URL) throws {
         let fd = try FileHandle._openFileDescriptorForURL(url, flags: O_RDONLY, reading: true)
         self.init(fileDescriptor: fd, closeOnDealloc: true)
     }
     
-    public convenience init(forWritingToURL url: URL) throws {
+    public convenience init(forWritingTo url: URL) throws {
         let fd = try FileHandle._openFileDescriptorForURL(url, flags: O_WRONLY, reading: false)
         self.init(fileDescriptor: fd, closeOnDealloc: true)
     }
 
-    public convenience init(forUpdatingURL url: URL) throws {
+    public convenience init(forUpdating url: URL) throws {
         let fd = try FileHandle._openFileDescriptorForURL(url, flags: O_RDWR, reading: false)
         self.init(fileDescriptor: fd, closeOnDealloc: true)
     }
@@ -330,7 +333,7 @@
     
     public override init() {
         /// the `pipe` system call creates two `fd` in a malloc'ed area
-        var fds = UnsafeMutablePointer<Int32>(allocatingCapacity: 2)
+        var fds = UnsafeMutablePointer<Int32>.allocate(capacity: 2)
         defer {
             free(fds)
         }
diff --git a/Foundation/NSFileManager.swift b/Foundation/NSFileManager.swift
index 8e283c8..f64064b 100644
--- a/Foundation/NSFileManager.swift
+++ b/Foundation/NSFileManager.swift
@@ -467,12 +467,12 @@
         } else if errno == ENOTEMPTY {
 
             let fsRep = FileManager.default().fileSystemRepresentation(withPath: path)
-            let ps = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 2)
-            ps.initialize(with: UnsafeMutablePointer(fsRep))
-            ps.advanced(by: 1).initialize(with: nil)
+            let ps = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: 2)
+            ps.initialize(to: UnsafeMutablePointer(fsRep))
+            ps.advanced(by: 1).initialize(to: nil)
             let stream = fts_open(ps, FTS_PHYSICAL | FTS_XDEV | FTS_NOCHDIR, nil)
             ps.deinitialize(count: 2)
-            ps.deallocateCapacity(2)
+            ps.deallocate(capacity: 2)
 
             if stream != nil {
                 defer {
@@ -701,13 +701,13 @@
         if len == kCFNotFound {
             fatalError("string could not be converted")
         }
-        let buf = UnsafeMutablePointer<Int8>(allocatingCapacity: len)
+        let buf = UnsafeMutablePointer<Int8>.allocate(capacity: len)
         for i in 0..<len {
-            buf.advanced(by: i).initialize(with: 0)
+            buf.advanced(by: i).initialize(to: 0)
         }
         if !path._nsObject.getFileSystemRepresentation(buf, maxLength: len) {
             buf.deinitialize(count: len)
-            buf.deallocateCapacity(len)
+            buf.deallocate(capacity: len)
             fatalError("string could not be converted")
         }
         return UnsafePointer(buf)
@@ -755,13 +755,12 @@
     }
     
     internal func _pathIsSymbolicLink(_ path: String) -> Bool {
-        guard let
-            attrs = try? attributesOfItem(atPath: path),
-            fileType = attrs[NSFileType] as? String
+        guard
+            let attrs = try? attributesOfItem(atPath: path),
+            let fileType = attrs[NSFileType] as? String
         else {
             return false
         }
-        
         return fileType == NSFileTypeSymbolicLink
     }
 }
@@ -914,12 +913,12 @@
             if let path = _url.path {
                 if FileManager.default().fileExists(atPath: path) {
                     let fsRep = FileManager.default().fileSystemRepresentation(withPath: path)
-                    let ps = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 2)
-                    ps.initialize(with: UnsafeMutablePointer(fsRep))
-                    ps.advanced(by: 1).initialize(with: nil)
+                    let ps = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: 2)
+                    ps.initialize(to: UnsafeMutablePointer(fsRep))
+                    ps.advanced(by: 1).initialize(to: nil)
                     _stream = fts_open(ps, FTS_PHYSICAL | FTS_XDEV | FTS_NOCHDIR, nil)
                     ps.deinitialize(count: 2)
-                    ps.deallocateCapacity(2)
+                    ps.deallocate(capacity: 2)
                 } else {
                     _rootError = _NSErrorWithErrno(ENOENT, reading: true, url: url)
                 }
@@ -999,7 +998,7 @@
         }
         
         override func skipDescendants() {
-            if let stream = _stream, current = _current {
+            if let stream = _stream, let current = _current {
                 fts_set(stream, current, FTS_SKIP)
             }
         }
diff --git a/Foundation/NSHTTPCookie.swift b/Foundation/NSHTTPCookie.swift
index 6fdc56a..7d70f2e 100644
--- a/Foundation/NSHTTPCookie.swift
+++ b/Foundation/NSHTTPCookie.swift
@@ -200,31 +200,31 @@
     /// - 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 init?(properties: [String : Any]) {
-        guard let
-            path = properties[NSHTTPCookiePath] as? String,
-            name = properties[NSHTTPCookieName] as? String,
-            value = properties[NSHTTPCookieValue] as? String
+        guard
+            let path = properties[NSHTTPCookiePath] as? String,
+            let name = properties[NSHTTPCookieName] as? String,
+            let value = properties[NSHTTPCookieValue] as? String
         else {
             return nil
         }
-        
+
         let canonicalDomain: String
         if let domain = properties[NSHTTPCookieDomain] as? String {
             canonicalDomain = domain
-        } else if let
-            originURL = properties[NSHTTPCookieOriginURL] as? URL,
-            host = originURL.host
+        } else if
+            let originURL = properties[NSHTTPCookieOriginURL] as? URL,
+            let host = originURL.host
         {
             canonicalDomain = host
         } else {
             return nil
         }
-        
+
         _path = path
         _name = name
         _value = value
         _domain = canonicalDomain
-        
+
         if let
             secureString = properties[NSHTTPCookieSecure] as? String
             where secureString.characters.count > 0
@@ -269,9 +269,9 @@
             } else {
                 _expiresDate = nil
             }
-        } else if let
-            maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
-            secondsFromNow = Int(maximumAge)
+        } else if
+            let maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
+            let secondsFromNow = Int(maximumAge)
             where _version == 1 {
             _expiresDate = Date(timeIntervalSinceNow: Double(secondsFromNow))
         } else {
diff --git a/Foundation/NSHost.swift b/Foundation/NSHost.swift
index 8f58264..afabb9d 100644
--- a/Foundation/NSHost.swift
+++ b/Foundation/NSHost.swift
@@ -92,12 +92,12 @@
                 }
                 let sa_len: socklen_t = socklen_t((family == AF_INET6) ? sizeof(sockaddr_in6.self) : sizeof(sockaddr_in.self))
                 let lookupInfo = { (content: inout [String], flags: Int32) in
-                    let hname = UnsafeMutablePointer<Int8>(allocatingCapacity: 1024)
+                    let hname = UnsafeMutablePointer<Int8>.allocate(capacity: 1024)
                     if (getnameinfo(info.ai_addr, sa_len, hname, 1024, nil, 0, flags) == 0) {
                         content.append(String(hname))
                     }
                     hname.deinitialize()
-                    hname.deallocateCapacity(1024)
+                    hname.deallocate(capacity: 1024)
                 }
                 lookupInfo(&_addresses, NI_NUMERICHOST)
                 lookupInfo(&_names, NI_NAMEREQD)
diff --git a/Foundation/NSJSONSerialization.swift b/Foundation/NSJSONSerialization.swift
index 5ff9578..365f441 100644
--- a/Foundation/NSJSONSerialization.swift
+++ b/Foundation/NSJSONSerialization.swift
@@ -637,10 +637,10 @@
                 memcpy(buffer.baseAddress!, address, min(count, temp_buffer_size - 1)) // ensure null termination
                 
                 let startPointer = UnsafePointer<Int8>(buffer.baseAddress!)
-                let intEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1)
-                defer { intEndPointer.deallocateCapacity(1) }
-                let doubleEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1)
-                defer { doubleEndPointer.deallocateCapacity(1) }
+                let intEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: 1)
+                defer { intEndPointer.deallocate(capacity: 1) }
+                let doubleEndPointer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: 1)
+                defer { doubleEndPointer.deallocate(capacity: 1) }
                 
                 let intResult = strtol(startPointer, intEndPointer, 10)
                 let intDistance = startPointer.distance(to: intEndPointer[0]!)
diff --git a/Foundation/NSKeyedArchiver.swift b/Foundation/NSKeyedArchiver.swift
index 7200204..d070a15 100644
--- a/Foundation/NSKeyedArchiver.swift
+++ b/Foundation/NSKeyedArchiver.swift
@@ -632,14 +632,14 @@
     }
     
     public override func encodePropertyList(_ aPropertyList: AnyObject) {
-        if !NSPropertyListClasses.contains({ $0 == aPropertyList.dynamicType }) {
+        if !NSPropertyListClasses.contains(where: { $0 == aPropertyList.dynamicType }) {
             fatalError("Cannot encode non-property list type \(aPropertyList.dynamicType) as property list")
         }
         encode(aPropertyList)
     }
     
     public func encodePropertyList(_ aPropertyList: AnyObject, forKey key: String) {
-        if !NSPropertyListClasses.contains({ $0 == aPropertyList.dynamicType }) {
+        if !NSPropertyListClasses.contains(where: { $0 == aPropertyList.dynamicType }) {
             fatalError("Cannot encode non-property list type \(aPropertyList.dynamicType) as property list")
         }
         encode(aPropertyList, forKey: key)
diff --git a/Foundation/NSKeyedCoderOldStyleArray.swift b/Foundation/NSKeyedCoderOldStyleArray.swift
index 4f319ee..75e9897 100644
--- a/Foundation/NSKeyedCoderOldStyleArray.swift
+++ b/Foundation/NSKeyedCoderOldStyleArray.swift
@@ -40,7 +40,7 @@
     deinit {
         if self._decoded {
             self._addr.deinitialize(count: self._count * self._size)
-            self._addr.deallocateCapacity(self._count * self._size)
+            self._addr.deallocate(capacity: self._count * self._size)
         }
     }
     
@@ -60,7 +60,7 @@
             return nil
         }
         
-        self._addr = UnsafeMutablePointer<UInt8>(allocatingCapacity: self._count * self._size)
+        self._addr = UnsafeMutablePointer<UInt8>.allocate(capacity: self._count * self._size)
         
         super.init()
         
@@ -94,7 +94,7 @@
     
     func fillObjCType(_ type: _NSSimpleObjCType, count: Int, at addr: UnsafeMutablePointer<Void>) {
         if type == self._type && count <= self._count {
-            UnsafeMutablePointer<UInt8>(addr).moveInitializeFrom(self._addr, count: count * self._size)
+            UnsafeMutablePointer<UInt8>(addr).moveInitialize(from: self._addr, count: count * self._size)
         }
     }
     
diff --git a/Foundation/NSKeyedUnarchiver.swift b/Foundation/NSKeyedUnarchiver.swift
index e2b59d4..43c9d57 100644
--- a/Foundation/NSKeyedUnarchiver.swift
+++ b/Foundation/NSKeyedUnarchiver.swift
@@ -242,7 +242,7 @@
         
         if _flags.contains(UnarchiverFlags.RequiresSecureCoding) {
             if let unwrappedAllowedClasses = allowedClasses {
-                if unwrappedAllowedClasses.contains({NSKeyedUnarchiver._classIsKindOfClass(assertedClass!, $0)}) {
+                if unwrappedAllowedClasses.contains(where: {NSKeyedUnarchiver._classIsKindOfClass(assertedClass!, $0)}) {
                     return true
                 }
             }
diff --git a/Foundation/NSLocale.swift b/Foundation/NSLocale.swift
index 919e3ad..b745c85 100644
--- a/Foundation/NSLocale.swift
+++ b/Foundation/NSLocale.swift
@@ -74,7 +74,7 @@
 }
 
 extension Locale {
-    public class func currentLocale() -> Locale {
+    public class var current: Locale {
         return CFLocaleCopyCurrent()._nsObject
     }
     
diff --git a/Foundation/NSLock.swift b/Foundation/NSLock.swift
index 599ebab..d19f203 100644
--- a/Foundation/NSLock.swift
+++ b/Foundation/NSLock.swift
@@ -23,7 +23,7 @@
 }
 
 public class Lock: NSObject, Locking {
-    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
+    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
     
     public override init() {
         pthread_mutex_init(mutex, nil)
@@ -32,7 +32,7 @@
     deinit {
         pthread_mutex_destroy(mutex)
         mutex.deinitialize()
-        mutex.deallocateCapacity(1)
+        mutex.deallocate(capacity: 1)
     }
     
     public func lock() {
@@ -136,7 +136,7 @@
 }
 
 public class RecursiveLock: NSObject, Locking {
-    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
+    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
     
     public override init() {
         super.init()
@@ -150,7 +150,7 @@
     deinit {
         pthread_mutex_destroy(mutex)
         mutex.deinitialize()
-        mutex.deallocateCapacity(1)
+        mutex.deallocate(capacity: 1)
     }
     
     public func lock() {
@@ -169,8 +169,8 @@
 }
 
 public class Condition: NSObject, Locking {
-    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
-    internal var cond = UnsafeMutablePointer<pthread_cond_t>(allocatingCapacity: 1)
+    internal var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
+    internal var cond = UnsafeMutablePointer<pthread_cond_t>.allocate(capacity: 1)
     
     public override init() {
         pthread_mutex_init(mutex, nil)
@@ -182,8 +182,8 @@
         pthread_cond_destroy(cond)
         mutex.deinitialize()
         cond.deinitialize()
-        mutex.deallocateCapacity(1)
-        cond.deallocateCapacity(1)
+        mutex.deallocate(capacity: 1)
+        cond.deallocate(capacity: 1)
     }
     
     public func lock() {
diff --git a/Foundation/NSNumber.swift b/Foundation/NSNumber.swift
index 74d1e94..1212526 100644
--- a/Foundation/NSNumber.swift
+++ b/Foundation/NSNumber.swift
@@ -130,7 +130,7 @@
     }
 }
 
-extension NSNumber : FloatLiteralConvertible, IntegerLiteralConvertible, BooleanLiteralConvertible {
+extension NSNumber : ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByBooleanLiteral {
 
 }
 
diff --git a/Foundation/NSNumberFormatter.swift b/Foundation/NSNumberFormatter.swift
index 8b35d2c..37082fd 100644
--- a/Foundation/NSNumberFormatter.swift
+++ b/Foundation/NSNumberFormatter.swift
@@ -164,7 +164,7 @@
         }
     }
     
-    internal var _locale: Locale = Locale.currentLocale()
+    internal var _locale: Locale = Locale.current
     /*@NSCopying*/ public var locale: Locale! {
         get {
             return _locale
diff --git a/Foundation/NSObject.swift b/Foundation/NSObject.swift
index 553ac11..346d83e 100644
--- a/Foundation/NSObject.swift
+++ b/Foundation/NSObject.swift
@@ -30,7 +30,7 @@
     }
 }
 
-public struct NSZone : NilLiteralConvertible {
+public struct NSZone : ExpressibleByNilLiteral {
     public init() {
         
     }
diff --git a/Foundation/NSOperation.swift b/Foundation/NSOperation.swift
index 9a08db5..f149ba9 100644
--- a/Foundation/NSOperation.swift
+++ b/Foundation/NSOperation.swift
@@ -26,24 +26,24 @@
     internal var _ready = false
     internal var _dependencies = Set<Operation>()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-    internal var _group = dispatch_group_create()
-    internal var _depGroup = dispatch_group_create()
-    internal var _groups = [dispatch_group_t]()
+    internal var _group = DispatchGroup()
+    internal var _depGroup = DispatchGroup()
+    internal var _groups = [DispatchGroup]()
 #endif
     
     public override init() {
         super.init()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        dispatch_group_enter(_group)
+        _group.enter()
 #endif
     }
     
     internal func _leaveGroups() {
         // assumes lock is taken
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        _groups.forEach() { dispatch_group_leave($0) }
+        _groups.forEach() { $0.leave() }
         _groups.removeAll()
-        dispatch_group_leave(_group)
+        _group.leave()
 #endif
     }
     
@@ -65,7 +65,7 @@
         // The completion block property is a bit cagey and can not be executed locally on the queue due to thread exhaust potentials.
         // This sets up for some strange behavior of finishing operations since the handler will be executed on a different queue
         if let completion = completionBlock {
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) { () -> Void in
+            DispatchQueue.global(attributes: .qosBackground).async { () -> Void in
                 completion()
             }
         }
@@ -74,7 +74,7 @@
     
     public func main() { }
     
-    public var cancelled: Bool {
+    public var isCancelled: Bool {
         return _cancelled
     }
     
@@ -85,20 +85,20 @@
         lock.unlock()
     }
     
-    public var executing: Bool {
+    public var isExecuting: Bool {
         return _executing
     }
     
-    public var finished: Bool {
+    public var isFinished: Bool {
         return _finished
     }
     
     // - Note: This property is NEVER used in the objective-c implementation!
-    public var asynchronous: Bool {
+    public var isAsynchronous: Bool {
         return false
     }
     
-    public var ready: Bool {
+    public var isReady: Bool {
         return _ready
     }
     
@@ -107,7 +107,7 @@
         _dependencies.insert(op)
         op.lock.lock()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        dispatch_group_enter(_depGroup)
+        _depGroup.enter()
         op._groups.append(_depGroup)
 #endif
         op.lock.unlock()
@@ -122,7 +122,7 @@
         let groupIndex = op._groups.index(where: { $0 === self._depGroup })
         if let idx = groupIndex {
             let group = op._groups.remove(at: idx)
-            dispatch_group_leave(group)
+            group.leave()
         }
 #endif
         op.lock.unlock()
@@ -140,7 +140,7 @@
     public var completionBlock: (() -> Void)?
     public func waitUntilFinished() {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        dispatch_group_wait(_group, DISPATCH_TIME_FOREVER)
+        _group.wait()
 #endif
     }
     
@@ -153,7 +153,7 @@
     
     internal func _waitUntilReady() {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        dispatch_group_wait(_depGroup, DISPATCH_TIME_FOREVER)
+        _depGroup.wait()
 #endif
         _ready = true
     }
@@ -296,14 +296,14 @@
 public class OperationQueue: NSObject {
     let lock = Lock()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-    var __concurrencyGate: dispatch_semaphore_t?
-    var __underlyingQueue: dispatch_queue_t?
-    let queueGroup = dispatch_group_create()
+    var __concurrencyGate: DispatchSemaphore?
+    var __underlyingQueue: DispatchQueue?
+    let queueGroup = DispatchGroup()
 #endif
     
     var _operations = _OperationList()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-    internal var _concurrencyGate: dispatch_semaphore_t? {
+    internal var _concurrencyGate: DispatchSemaphore? {
         get {
             lock.lock()
             let val = __concurrencyGate
@@ -314,7 +314,7 @@
 
     // This is NOT the behavior of the objective-c variant; it will never re-use a queue and instead for every operation it will create a new one.
     // However this is considerably faster and probably more effecient.
-    internal var _underlyingQueue: dispatch_queue_t {
+    internal var _underlyingQueue: DispatchQueue {
         lock.lock()
         if let queue = __underlyingQueue {
             lock.unlock()
@@ -326,18 +326,18 @@
             } else {
                 effectiveName = "NSOperationQueue::\(unsafeAddress(of: self))"
             }
-            let attr: dispatch_queue_attr_t?
+            let attr: DispatchQueueAttributes
             if maxConcurrentOperationCount == 1 {
-                attr = DISPATCH_QUEUE_SERIAL
+                attr = .serial
             } else {
-                attr = DISPATCH_QUEUE_CONCURRENT
+                attr = .concurrent
                 if maxConcurrentOperationCount != NSOperationQueueDefaultMaxConcurrentOperationCount {
-                    __concurrencyGate = dispatch_semaphore_create(maxConcurrentOperationCount)
+                    __concurrencyGate = DispatchSemaphore(value:maxConcurrentOperationCount)
                 }
             }
-            let queue = dispatch_queue_create(effectiveName, attr)
+            let queue = DispatchQueue(label: effectiveName, attributes: attr)
             if _suspended {
-                dispatch_suspend(queue)
+                queue.suspend()
             }
             __underlyingQueue = queue
             lock.unlock()
@@ -351,12 +351,11 @@
     }
 
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-    internal init(_queue queue: dispatch_queue_t, maxConcurrentOperations: Int = NSOperationQueueDefaultMaxConcurrentOperationCount) {
+    internal init(_queue queue: DispatchQueue, maxConcurrentOperations: Int = NSOperationQueueDefaultMaxConcurrentOperationCount) {
         __underlyingQueue = queue
         maxConcurrentOperationCount = maxConcurrentOperations
         super.init()
-        dispatch_queue_set_specific(queue, OperationQueue.OperationQueueKey, unsafeBitCast(Unmanaged.passUnretained(self), to: UnsafeMutablePointer<Void>.self), nil)
-        
+        queue.setSpecific(key: OperationQueue.OperationQueueKey, value: Unmanaged.passUnretained(self))
     }
 #endif
 
@@ -373,9 +372,9 @@
     
     internal func _runOperation() {
         if let op = _dequeueOperation() {
-            if !op.cancelled {
+            if !op.isCancelled {
                 op._waitUntilReady()
-                if !op.cancelled {
+                if !op.isCancelled {
                     op.start()
                 }
             }
@@ -384,13 +383,13 @@
     
     public func addOperations(_ ops: [Operation], waitUntilFinished wait: Bool) {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        var waitGroup: dispatch_group_t?
+        var waitGroup: DispatchGroup?
         if wait {
-            waitGroup = dispatch_group_create()
+            waitGroup = DispatchGroup()
         }
 #endif
         /*
-         If OperationQueuePriority was not supported this could be much faster
+         If QueuePriority was not supported this could be much faster
          since it would not need to have the extra book-keeping for managing a priority
          queue. However this implementation attempts to be similar to the specification.
          As a concequence this means that the dequeue may NOT nessicarly be the same as
@@ -406,27 +405,27 @@
             lock.unlock()
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
             if let group = waitGroup {
-                dispatch_group_enter(group)
+                group.enter()
             }
-            
-            let block = dispatch_block_create(DISPATCH_BLOCK_ENFORCE_QOS_CLASS) { () -> Void in
+
+            let block = DispatchWorkItem(group: queueGroup, flags: .enforceQoS) { () -> Void in
                 if let sema = self._concurrencyGate {
-                    dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
+                    sema.wait()
                     self._runOperation()
-                    dispatch_semaphore_signal(sema)
+                    sema.signal()
                 } else {
                     self._runOperation()
                 }
                 if let group = waitGroup {
-                    dispatch_group_leave(group)
+                    group.leave()
                 }
             }
-            dispatch_group_async(queueGroup, _underlyingQueue, block)
+            _underlyingQueue.async(execute: block)
 #endif
         }
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
         if let group = waitGroup {
-            dispatch_group_wait(group, DISPATCH_TIME_FOREVER)
+            group.wait()
         }
 #endif
     }
@@ -474,9 +473,9 @@
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
                 if let queue = __underlyingQueue {
                     if newValue {
-                        dispatch_suspend(queue)
+                        queue.suspend()
                     } else {
-                        dispatch_resume(queue)
+                        queue.resume()
                     }
                 }
 #endif
@@ -507,7 +506,7 @@
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
     // Note: this will return non nil whereas the objective-c version will only return non nil when it has been set.
     // it uses a target queue assignment instead of returning the actual underlying queue.
-    public var underlyingQueue: dispatch_queue_t? {
+    public var underlyingQueue: DispatchQueue? {
         get {
             lock.lock()
             let queue = __underlyingQueue
@@ -531,15 +530,17 @@
     
     public func waitUntilAllOperationsAreFinished() {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        dispatch_group_wait(queueGroup, DISPATCH_TIME_FOREVER)
+        queueGroup.wait()
 #endif
     }
     
-    static let OperationQueueKey = UnsafePointer<Void>(UnsafeMutablePointer<Void>(allocatingCapacity: 1))
-    
+#if DEPLOYMENT_ENABLE_LIBDISPATCH
+    static let OperationQueueKey = DispatchSpecificKey<Unmanaged<OperationQueue>>()
+#endif
+
     public class func currentQueue() -> OperationQueue? {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        let specific = dispatch_get_specific(OperationQueue.OperationQueueKey)
+        let specific = DispatchQueue.getSpecific(key: OperationQueue.OperationQueueKey)
         if specific == nil {
             if pthread_main_np() == 1 {
                 return OperationQueue.mainQueue()
@@ -547,7 +548,7 @@
                 return nil
             }
         } else {
-            return Unmanaged<OperationQueue>.fromOpaque(unsafeBitCast(specific, to: UnsafePointer<Void>.self)).takeUnretainedValue()
+            return specific!.takeUnretainedValue()
         }
 #else
         return nil
@@ -556,11 +557,11 @@
     
     public class func mainQueue() -> OperationQueue {
 #if DEPLOYMENT_ENABLE_LIBDISPATCH
-        let specific = dispatch_queue_get_specific(dispatch_get_main_queue(), OperationQueue.OperationQueueKey)
+        let specific = DispatchQueue.main.getSpecific(key: OperationQueue.OperationQueueKey)
         if specific == nil {
-            return OperationQueue(_queue: dispatch_get_main_queue(), maxConcurrentOperations: 1)
+            return OperationQueue(_queue: DispatchQueue.main, maxConcurrentOperations: 1)
         } else {
-            return Unmanaged<OperationQueue>.fromOpaque(unsafeBitCast(specific, to: UnsafePointer<Void>.self)).takeUnretainedValue()
+            return specific!.takeUnretainedValue()
         }
 #else
         fatalError("NSOperationQueue requires libdispatch")
diff --git a/Foundation/NSOrderedSet.swift b/Foundation/NSOrderedSet.swift
index 2f5fe9b..c19c280 100644
--- a/Foundation/NSOrderedSet.swift
+++ b/Foundation/NSOrderedSet.swift
@@ -8,7 +8,7 @@
 //
 
 /****************       Immutable Ordered Set   ****************/
-public class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, ArrayLiteralConvertible {
+public class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, ExpressibleByArrayLiteral {
     internal var _storage: Set<NSObject>
     internal var _orderedStorage: [NSObject]
     
@@ -285,13 +285,13 @@
     }
 
     public convenience init(array: [AnyObject]) {
-        let buffer = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: array.count)
+        let buffer = UnsafeMutablePointer<AnyObject?>.allocate(capacity: array.count)
         for (idx, element) in array.enumerated() {
-            buffer.advanced(by: idx).initialize(with: element)
+            buffer.advanced(by: idx).initialize(to: element)
         }
         self.init(objects: buffer, count: array.count)
         buffer.deinitialize(count: array.count)
-        buffer.deallocateCapacity(array.count)
+        buffer.deallocate(capacity: array.count)
     }
 
     public convenience init(array set: [AnyObject], copyItems flag: Bool) {
@@ -351,7 +351,8 @@
             fatalError("\(self): Index out of bounds")
         }
 
-        if let objectToReplace = objectAtIndex(idx) as? NSObject, object = object as? NSObject {
+        if let objectToReplace = objectAtIndex(idx) as? NSObject,
+           let object = object as? NSObject {
             _orderedStorage[idx] = object
             _storage.remove(objectToReplace)
             _storage.insert(object)
@@ -401,7 +402,8 @@
             fatalError("\(self): Index out of bounds")
         }
 
-        if let object1 = objectAtIndex(idx1) as? NSObject, object2 = objectAtIndex(idx2) as? NSObject {
+        if let object1 = objectAtIndex(idx1) as? NSObject,
+           let object2 = objectAtIndex(idx2) as? NSObject {
             _orderedStorage[idx1] = object2
             _orderedStorage[idx2] = object1
         }
diff --git a/Foundation/NSScanner.swift b/Foundation/NSScanner.swift
index 62c01a6..873bfd0 100644
--- a/Foundation/NSScanner.swift
+++ b/Foundation/NSScanner.swift
@@ -282,7 +282,7 @@
         }
         return "."
     } else {
-        return decimalSep(Locale.currentLocale())
+        return decimalSep(Locale.current)
     }
 }
 
diff --git a/Foundation/NSSet.swift b/Foundation/NSSet.swift
index 6eff146..582d6e2 100644
--- a/Foundation/NSSet.swift
+++ b/Foundation/NSSet.swift
@@ -12,16 +12,16 @@
 
 extension Set : _ObjectTypeBridgeable {
     public func _bridgeToObject() -> NSSet {
-        let buffer = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: count)
+        let buffer = UnsafeMutablePointer<AnyObject?>.allocate(capacity: count)
         
         for (idx, obj) in enumerated() {
-            buffer.advanced(by: idx).initialize(with: _NSObjectRepresentableBridge(obj))
+            buffer.advanced(by: idx).initialize(to: _NSObjectRepresentableBridge(obj))
         }
         
         let set = NSSet(objects: buffer, count: count)
         
         buffer.deinitialize(count: count)
-        buffer.deallocateCapacity(count)
+        buffer.deallocate(capacity: count)
         
         return set
     }
@@ -43,7 +43,7 @@
             let cf = x._cfObject
             let cnt = CFSetGetCount(cf)
             
-            let objs = UnsafeMutablePointer<UnsafePointer<Void>?>(allocatingCapacity: cnt)
+            let objs = UnsafeMutablePointer<UnsafePointer<Void>?>.allocate(capacity: cnt)
             
             CFSetGetValues(cf, objs)
             
@@ -57,7 +57,7 @@
                 }
             }
             objs.deinitialize(count: cnt)
-            objs.deallocateCapacity(cnt)
+            objs.deallocate(capacity: cnt)
         }
         if !failedConversion {
             result = set
@@ -122,13 +122,13 @@
             withUnsafeMutablePointer(&cnt) { (ptr: UnsafeMutablePointer<UInt32>) -> Void in
                 aDecoder.decodeValue(ofObjCType: "i", at: UnsafeMutablePointer<Void>(ptr))
             }
-            let objects = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: Int(cnt))
+            let objects = UnsafeMutablePointer<AnyObject?>.allocate(capacity: Int(cnt))
             for idx in 0..<cnt {
-                objects.advanced(by: Int(idx)).initialize(with: aDecoder.decodeObject())
+                objects.advanced(by: Int(idx)).initialize(to: aDecoder.decodeObject())
             }
             self.init(objects: UnsafePointer<AnyObject?>(objects), count: Int(cnt))
             objects.deinitialize(count: Int(cnt))
-            objects.deallocateCapacity(Int(cnt))
+            objects.deallocate(capacity: Int(cnt))
         } else if aDecoder.dynamicType == NSKeyedUnarchiver.self || aDecoder.containsValue(forKey: "NS.objects") {
             let objects = aDecoder._decodeArrayOfObjectsForKey("NS.objects")
             self.init(array: objects)
@@ -201,13 +201,13 @@
     }
 
     public convenience init(array: [AnyObject]) {
-        let buffer = UnsafeMutablePointer<AnyObject?>(allocatingCapacity: array.count)
+        let buffer = UnsafeMutablePointer<AnyObject?>.allocate(capacity: array.count)
         for (idx, element) in array.enumerated() {
-            buffer.advanced(by: idx).initialize(with: element)
+            buffer.advanced(by: idx).initialize(to: element)
         }
         self.init(objects: buffer, count: array.count)
         buffer.deinitialize(count: array.count)
-        buffer.deallocateCapacity(array.count)
+        buffer.deallocate(capacity: array.count)
     }
 
     public convenience init(set: Set<NSObject>) {
@@ -382,7 +382,7 @@
         super.init(objects: [], count: 0)
     }
     
-    public required convenience init?(coder: NSCoder) {
+    public required convenience init?(coder aDecoder: NSCoder) {
         NSUnimplemented()
     }
     
diff --git a/Foundation/NSStream.swift b/Foundation/NSStream.swift
index a48a5e8..ee1a9e1 100644
--- a/Foundation/NSStream.swift
+++ b/Foundation/NSStream.swift
@@ -7,6 +7,16 @@
 // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
 //
 
+import CoreFoundation
+
+#if os(OSX) || os(iOS)
+internal extension UInt {
+    init(_ status: CFStreamStatus) {
+        self.init(status.rawValue)
+    }
+}
+#endif
+
 extension Stream {
     public struct PropertyKey : RawRepresentable, Equatable, Hashable, Comparable {
         public private(set) var rawValue: String
@@ -60,17 +70,17 @@
 // NSStream is an abstract class encapsulating the common API to NSInputStream and NSOutputStream.
 // Subclassers of NSInputStream and NSOutputStream must also implement these methods.
 public class Stream: NSObject {
-    
+
     public override init() {
-        
+
     }
     
     public func open() {
-        NSUnimplemented()
+        NSRequiresConcreteImplementation()
     }
     
     public func close() {
-        NSUnimplemented()
+        NSRequiresConcreteImplementation()
     }
     
     public weak var delegate: StreamDelegate?
@@ -95,7 +105,7 @@
     }
     
     public var streamStatus: Status {
-        NSUnimplemented()
+        NSRequiresConcreteImplementation()
     }
     
     /*@NSCopying */public var streamError: NSError? {
@@ -106,9 +116,12 @@
 // NSInputStream is an abstract class representing the base functionality of a read stream.
 // Subclassers are required to implement these methods.
 public class InputStream: Stream {
+
+    private var _stream: CFReadStream!
+
     // reads up to length bytes into the supplied buffer, which must be at least of size len. Returns the actual number of bytes read.
     public func read(_ buffer: UnsafeMutablePointer<UInt8>, maxLength len: Int) -> Int {
-        NSUnimplemented()
+        return CFReadStreamRead(_stream, buffer, CFIndex(len._bridgeToObject()))
     }
     
     // returns in O(1) a pointer to the buffer in 'buffer' and by reference in 'len' how many bytes are available. This buffer is only valid until the next stream operation. Subclassers may return NO for this if it is not appropriate for the stream type. This may return NO if the buffer is not available.
@@ -118,19 +131,31 @@
     
     // returns YES if the stream has bytes available or if it impossible to tell without actually doing the read.
     public var hasBytesAvailable: Bool {
-        NSUnimplemented()
+        return CFReadStreamHasBytesAvailable(_stream)
     }
     
     public init(data: Data) {
-        NSUnimplemented()
+        _stream = CFReadStreamCreateWithData(kCFAllocatorSystemDefault, data._cfObject)
     }
     
     public init?(url: URL) {
-        NSUnimplemented()
+        _stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url._cfObject)
     }
 
     public convenience init?(fileAtPath path: String) {
-        NSUnimplemented()
+        self.init(url: URL(fileURLWithPath: path))
+    }
+
+    public override func open() {
+        CFReadStreamOpen(_stream)
+    }
+    
+    public override func close() {
+        CFReadStreamClose(_stream)
+    }
+    
+    public override var streamStatus: Status {
+        return Stream.Status(rawValue: UInt(CFReadStreamGetStatus(_stream)))!
     }
 }
 
@@ -138,34 +163,58 @@
 // Subclassers are required to implement these methods.
 // Currently this is left as named NSOutputStream due to conflicts with the standard library's text streaming target protocol named OutputStream (which ideally should be renamed)
 public class NSOutputStream : Stream {
+    
+    private  var _stream: CFWriteStream!
+    
     // writes the bytes from the specified buffer to the stream up to len bytes. Returns the number of bytes actually written.
     public func write(_ buffer: UnsafePointer<UInt8>, maxLength len: Int) -> Int {
-        NSUnimplemented()
+        return  CFWriteStreamWrite(_stream, buffer, len)
     }
     
     // returns YES if the stream can be written to or if it is impossible to tell without actually doing the write.
     public var hasSpaceAvailable: Bool {
-        NSUnimplemented()
+        return CFWriteStreamCanAcceptBytes(_stream)
     }
     
-    public init(toMemory: ()) {
-        NSUnimplemented()
+    required public init(toMemory: ()) {
+        _stream = CFWriteStreamCreateWithAllocatedBuffers(kCFAllocatorDefault, kCFAllocatorDefault)
     }
 
     public init(toBuffer buffer: UnsafeMutablePointer<UInt8>, capacity: Int) {
-        NSUnimplemented()
+        _stream = CFWriteStreamCreateWithBuffer(kCFAllocatorSystemDefault, buffer, capacity)
     }
-
+    
     public init?(url: URL, append shouldAppend: Bool) {
-        NSUnimplemented()
+        _stream = CFWriteStreamCreateWithFile(kCFAllocatorSystemDefault, url._cfObject)
+        CFWriteStreamSetProperty(_stream, kCFStreamPropertyAppendToFile, shouldAppend._cfObject)
     }
     
     public convenience init?(toFileAtPath path: String, append shouldAppend: Bool) {
-        NSUnimplemented()
+        self.init(url: URL(fileURLWithPath: path), append: shouldAppend)
+    }
+    
+    public override func open() {
+        CFWriteStreamOpen(_stream)
+    }
+    
+    public override func close() {
+        CFWriteStreamClose(_stream)
+    }
+    
+    public override var streamStatus: Status {
+        return Stream.Status(rawValue: UInt(CFWriteStreamGetStatus(_stream)))!
     }
     
     public class func outputStreamToMemory() -> Self {
-        NSUnimplemented()
+        return self.init(toMemory: ())
+    }
+    
+    public override func propertyForKey(_ key: String) -> AnyObject? {
+        return CFWriteStreamCopyProperty(_stream, key._cfObject)
+    }
+    
+    public  override func setProperty(_ property: AnyObject?, forKey key: String) -> Bool {
+        return CFWriteStreamSetProperty(_stream, key._cfObject, property)
     }
 }
 
diff --git a/Foundation/NSString.swift b/Foundation/NSString.swift
index 44ddeb9..f1b1a5c 100644
--- a/Foundation/NSString.swift
+++ b/Foundation/NSString.swift
@@ -12,7 +12,7 @@
 
 public typealias unichar = UInt16
 
-extension unichar : UnicodeScalarLiteralConvertible {
+extension unichar : ExpressibleByUnicodeScalarLiteral {
     public typealias UnicodeScalarLiteralType = UnicodeScalar
     
     public init(unicodeScalarLiteral scalar: UnicodeScalar) {
@@ -91,12 +91,12 @@
                 result = String(cString: str!)
             } else {
                 let length = CFStringGetLength(cf)
-                let buffer = UnsafeMutablePointer<UniChar>(allocatingCapacity: length)
+                let buffer = UnsafeMutablePointer<UniChar>.allocate(capacity: length)
                 CFStringGetCharacters(cf, CFRangeMake(0, length), buffer)
                 
                 let str = String._fromCodeUnitSequence(UTF16.self, input: UnsafeBufferPointer(start: buffer, count: length))
                 buffer.deinitialize(count: length)
-                buffer.deallocateCapacity(length)
+                buffer.deallocate(capacity: length)
                 result = str
             }
         } else if x.dynamicType == _NSCFConstantString.self {
@@ -192,7 +192,7 @@
         fatalError("Internal inconsistency; previously claimed getBytes returned success but failed with similar invocation")
     }
     
-    UnsafeMutablePointer<Int8>(buffer).advanced(by: cLength).initialize(with: 0)
+    UnsafeMutablePointer<Int8>(buffer).advanced(by: cLength).initialize(to: 0)
     
     return UnsafePointer<Int8>(buffer) // leaked and should be autoreleased via a NSData backing but we cannot here
 }
@@ -278,11 +278,11 @@
                 return NSMutableString(characters: contents, length: length)
             }
         }
-        let characters = UnsafeMutablePointer<unichar>(allocatingCapacity: length)
+        let characters = UnsafeMutablePointer<unichar>.allocate(capacity: length)
         getCharacters(characters, range: NSMakeRange(0, length))
         let result = NSMutableString(characters: characters, length: length)
         characters.deinitialize()
-        characters.deallocateCapacity(length)
+        characters.deallocate(capacity: length)
         return result
     }
     
@@ -388,11 +388,11 @@
             let max = start.advanced(by: range.location + range.length)
             return String(_storage.utf16[min..<max])
         } else {
-            let buff = UnsafeMutablePointer<unichar>(allocatingCapacity: range.length)
+            let buff = UnsafeMutablePointer<unichar>.allocate(capacity: range.length)
             getCharacters(buff, range: range)
             let result = String(buff)
             buff.deinitialize()
-            buff.deallocateCapacity(range.length)
+            buff.deallocate(capacity: range.length)
             return result
         }
     }
@@ -424,15 +424,15 @@
     }
     
     public func localizedCompare(_ string: String) -> ComparisonResult {
-        return compare(string, options: [], range: NSMakeRange(0, length), locale: Locale.currentLocale())
+        return compare(string, options: [], range: NSMakeRange(0, length), locale: Locale.current)
     }
     
     public func localizedCaseInsensitiveCompare(_ string: String) -> ComparisonResult {
-        return compare(string, options: .caseInsensitive, range: NSMakeRange(0, length), locale: Locale.currentLocale())
+        return compare(string, options: .caseInsensitive, range: NSMakeRange(0, length), locale: Locale.current)
     }
     
     public func localizedStandardCompare(_ string: String) -> ComparisonResult {
-        return compare(string, options: [.caseInsensitive, .numeric, .widthInsensitive, .forcedOrdering], range: NSMakeRange(0, length), locale: Locale.currentLocale())
+        return compare(string, options: [.caseInsensitive, .numeric, .widthInsensitive, .forcedOrdering], range: NSMakeRange(0, length), locale: Locale.current)
     }
     
     public func isEqual(to aString: String) -> Bool {
@@ -502,15 +502,15 @@
     }
     
     public func localizedCaseInsensitiveContains(_ str: String) -> Bool {
-        return range(of: str, options: .caseInsensitive, range: NSMakeRange(0, length), locale: Locale.currentLocale()).location != NSNotFound
+        return range(of: str, options: .caseInsensitive, range: NSMakeRange(0, length), locale: Locale.current).location != NSNotFound
     }
     
     public func localizedStandardContains(_ str: String) -> Bool {
-        return range(of: str, options: [.caseInsensitive, .diacriticInsensitive], range: NSMakeRange(0, length), locale: Locale.currentLocale()).location != NSNotFound
+        return range(of: str, options: [.caseInsensitive, .diacriticInsensitive], range: NSMakeRange(0, length), locale: Locale.current).location != NSNotFound
     }
     
     public func localizedStandardRange(of str: String) -> NSRange {
-        return range(of: str, options: [.caseInsensitive, .diacriticInsensitive], range: NSMakeRange(0, length), locale: Locale.currentLocale())
+        return range(of: str, options: [.caseInsensitive, .diacriticInsensitive], range: NSMakeRange(0, length), locale: Locale.current)
     }
     
     public func range(of searchString: String) -> NSRange {
@@ -677,15 +677,15 @@
     }
     
     public var localizedUppercase: String {
-        return uppercased(with: Locale.currentLocale())
+        return uppercased(with: Locale.current)
     }
     
     public var localizedLowercase: String {
-        return lowercased(with: Locale.currentLocale())
+        return lowercased(with: Locale.current)
     }
     
     public var localizedCapitalized: String {
-        return capitalized(with: Locale.currentLocale())
+        return capitalized(with: Locale.current)
     }
     
     public func uppercased(with locale: Locale?) -> String {
@@ -882,14 +882,14 @@
         if self.dynamicType == NSString.self || self.dynamicType == NSMutableString.self {
             if _storage._core.isASCII {
                 used = min(self.length, maxBufferCount - 1)
-                buffer.moveAssignFrom(unsafeBitCast(_storage._core.startASCII, to: UnsafeMutablePointer<Int8>.self)
+                buffer.moveAssign(from: unsafeBitCast(_storage._core.startASCII, to: UnsafeMutablePointer<Int8>.self)
                     , count: used)
-                buffer.advanced(by: used).initialize(with: 0)
+                buffer.advanced(by: used).initialize(to: 0)
                 return true
             }
         }
         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)
+            buffer.advanced(by: used).initialize(to: 0)
             return true
         }
         return false
@@ -944,7 +944,7 @@
                     numEncodings += 1
                 }
                 
-                let theEncodingList = UnsafeMutablePointer<String.Encoding.RawValue>(allocatingCapacity: numEncodings + 1)
+                let theEncodingList = UnsafeMutablePointer<String.Encoding.RawValue>.allocate(capacity: numEncodings + 1)
                 theEncodingList.advanced(by: numEncodings).pointee = 0 // Terminator
                 
                 numEncodings -= 1
@@ -1290,7 +1290,7 @@
     }
 }
 
-extension NSString : StringLiteralConvertible { }
+extension NSString : ExpressibleByStringLiteral { }
 
 public class NSMutableString : NSString {
     public func replaceCharacters(in range: NSRange, with aString: String) {
diff --git a/Foundation/NSSwiftRuntime.swift b/Foundation/NSSwiftRuntime.swift
index 90d82a0..0f4616b 100644
--- a/Foundation/NSSwiftRuntime.swift
+++ b/Foundation/NSSwiftRuntime.swift
@@ -352,10 +352,10 @@
         if let fastpath = fastpath {
             return body(fastpath)
         } else if self.count > count {
-            let buffer = UnsafeMutablePointer<Element>(allocatingCapacity: count)
+            let buffer = UnsafeMutablePointer<Element>.allocate(capacity: count)
             let res = body(buffer)
             buffer.deinitialize(count: count)
-            buffer.deallocateCapacity(count)
+            buffer.deallocate(capacity: count)
             return res
         } else {
             return withUnsafeMutableBufferPointer() { (bufferPtr: inout UnsafeMutableBufferPointer<Element>) -> R in
diff --git a/Foundation/NSTask.swift b/Foundation/NSTask.swift
index 4094fbd..8b8c9bd 100644
--- a/Foundation/NSTask.swift
+++ b/Foundation/NSTask.swift
@@ -204,8 +204,8 @@
         
         let argv : UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> = args.withUnsafeBufferPointer {
             let array : UnsafeBufferPointer<String> = $0
-            let buffer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: array.count + 1)
-            buffer.initializeFrom(array.map { $0.withCString(strdup) })
+            let buffer = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: array.count + 1)
+            buffer.initialize(from: array.map { $0.withCString(strdup) })
             buffer[array.count] = nil
             return buffer
         }
@@ -215,15 +215,15 @@
                 free(UnsafeMutablePointer<Void>(arg.pointee))
             }
             
-            argv.deallocateCapacity(args.count + 1)
+            argv.deallocate(capacity: args.count + 1)
         }
         
         let envp: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
         
         if let env = environment {
             let nenv = env.count
-            envp = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>(allocatingCapacity: 1 + nenv)
-            envp.initializeFrom(env.map { strdup("\($0)=\($1)") })
+            envp = UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>.allocate(capacity: 1 + nenv)
+            envp.initialize(from: env.map { strdup("\($0)=\($1)") })
             envp[env.count] = nil
         } else {
             envp = _CFEnviron()
@@ -234,7 +234,7 @@
                 for pair in envp ..< envp + env.count {
                     free(UnsafeMutablePointer<Void>(pair.pointee))
                 }
-                envp.deallocateCapacity(env.count + 1)
+                envp.deallocate(capacity: env.count + 1)
             }
         }
 
@@ -305,33 +305,49 @@
         posix(posix_spawn_file_actions_init(&fileActions))
         defer { posix_spawn_file_actions_destroy(&fileActions) }
 
+        // File descriptors to duplicate in the child process. This allows
+        // output redirection to NSPipe or NSFileHandle.
+        var adddup2 = [Int32: Int32]()
+
+        // File descriptors to close in the child process. A set so that
+        // shared pipes only get closed once. Would result in EBADF on OSX
+        // otherwise.
+        var addclose = Set<Int32>()
+
         switch standardInput {
         case let pipe as Pipe:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, pipe.fileHandleForReading.fileDescriptor, STDIN_FILENO))
-            posix(posix_spawn_file_actions_addclose(&fileActions, pipe.fileHandleForWriting.fileDescriptor))
+            adddup2[STDIN_FILENO] = pipe.fileHandleForReading.fileDescriptor
+            addclose.insert(pipe.fileHandleForWriting.fileDescriptor)
         case let handle as FileHandle:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, handle.fileDescriptor, STDIN_FILENO))
+            adddup2[STDIN_FILENO] = handle.fileDescriptor
         default: break
         }
 
         switch standardOutput {
         case let pipe as Pipe:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, pipe.fileHandleForWriting.fileDescriptor, STDOUT_FILENO))
-            posix(posix_spawn_file_actions_addclose(&fileActions, pipe.fileHandleForReading.fileDescriptor))
+            adddup2[STDOUT_FILENO] = pipe.fileHandleForWriting.fileDescriptor
+            addclose.insert(pipe.fileHandleForReading.fileDescriptor)
         case let handle as FileHandle:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, handle.fileDescriptor, STDOUT_FILENO))
+            adddup2[STDOUT_FILENO] = handle.fileDescriptor
         default: break
         }
 
         switch standardError {
         case let pipe as Pipe:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, pipe.fileHandleForWriting.fileDescriptor, STDERR_FILENO))
-            posix(posix_spawn_file_actions_addclose(&fileActions, pipe.fileHandleForReading.fileDescriptor))
+            adddup2[STDERR_FILENO] = pipe.fileHandleForWriting.fileDescriptor
+            addclose.insert(pipe.fileHandleForReading.fileDescriptor)
         case let handle as FileHandle:
-            posix(posix_spawn_file_actions_adddup2(&fileActions, handle.fileDescriptor, STDERR_FILENO))
+            adddup2[STDERR_FILENO] = handle.fileDescriptor
         default: break
         }
 
+        for (new, old) in adddup2 {
+            posix(posix_spawn_file_actions_adddup2(&fileActions, old, new))
+        }
+        for fd in addclose {
+            posix(posix_spawn_file_actions_addclose(&fileActions, fd))
+        }
+
         // Launch
 
         var pid = pid_t()
diff --git a/Foundation/NSThread.swift b/Foundation/NSThread.swift
index 370439b..ced09dd 100644
--- a/Foundation/NSThread.swift
+++ b/Foundation/NSThread.swift
@@ -59,7 +59,7 @@
 public class Thread: NSObject {
     
     static internal var _currentThread = NSThreadSpecific<Thread>()
-    public static func current() -> Thread {
+    public static var current: Thread {
         return Thread._currentThread.get() {
             return Thread(thread: pthread_self())
         }
diff --git a/Foundation/NSURL.swift b/Foundation/NSURL.swift
index 816e9a3..4ba842e 100644
--- a/Foundation/NSURL.swift
+++ b/Foundation/NSURL.swift
@@ -499,9 +499,9 @@
         
         let bufSize = Int(PATH_MAX + 1)
         
-        let _fsrBuffer = UnsafeMutablePointer<Int8>(allocatingCapacity: bufSize)
+        let _fsrBuffer = UnsafeMutablePointer<Int8>.allocate(capacity: bufSize)
         for i in 0..<bufSize {
-            _fsrBuffer.advanced(by: i).initialize(with: 0)
+            _fsrBuffer.advanced(by: i).initialize(to: 0)
         }
         
         if getFileSystemRepresentation(_fsrBuffer, maxLength: bufSize) {
@@ -521,7 +521,20 @@
     
     /* A string constant for the "file" URL scheme. If you are using this to compare to a URL's scheme to see if it is a file URL, you should instead use the NSURL fileURL property -- the fileURL property is much faster. */
     public var standardized: URL? {
-        NSUnimplemented()
+        guard (path != nil) else {
+            return nil
+        }
+
+        let URLComponents = NSURLComponents(string: relativeString)
+        guard ((URLComponents != nil) && (URLComponents!.path != nil)) else {
+            return nil
+        }
+        guard (URLComponents!.path!.contains("..") || URLComponents!.path!.contains(".")) else{
+            return URLComponents!.url(relativeTo: baseURL)
+        }
+
+        URLComponents!.path! = _pathByRemovingDots(pathComponents!)
+        return URLComponents!.url(relativeTo: baseURL)
     }
     
     /* Returns whether the URL's resource exists and is reachable. This method synchronously checks if the resource's backing store is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, e.g. periodic maintenance of UI state that depends on the existence of a specific document. When performing operations such as opening a file or copying resource properties, it is more efficient to simply try the operation and handle failures. If this method returns NO, the optional error is populated. This method is currently applicable only to URLs for file system resources. For other URL types, NO is returned. Symbol is present in iOS 4, but performs no operation.
@@ -535,7 +548,11 @@
     /* Returns a file path URL that refers to the same resource as a specified URL. File path URLs use a file system style path. An error will occur if the url parameter is not a file URL. A file reference URL's resource must exist and be reachable to be converted to a file path URL. Symbol is present in iOS 4, but performs no operation.
     */
     public var filePathURL: URL? {
-        NSUnimplemented()
+        guard isFileURL else {
+            return nil
+        }
+
+        return URL(string: absoluteString)
     }
     
     override public var _cfTypeID: CFTypeID {
@@ -675,7 +692,8 @@
     public func appendingPathComponent(_ pathComponent: String) -> URL? {
         var result : URL? = appendingPathComponent(pathComponent, isDirectory: false)
         if !pathComponent.hasSuffix("/") && isFileURL {
-            if let urlWithoutDirectory = result, path = urlWithoutDirectory.path {
+            if let urlWithoutDirectory = result,
+               let path = urlWithoutDirectory.path {
                 var isDir : Bool = false
                 if FileManager.default().fileExists(atPath: path, isDirectory: &isDir) && isDir {
                     result = self.appendingPathComponent(pathComponent, isDirectory: true)
@@ -769,6 +787,38 @@
         
         return URL(fileURLWithPath: resolvedPath)
     }
+
+    private func _pathByRemovingDots(_ comps: [String]) -> String {
+        var components = comps
+        
+        if(components.last == "/") {
+            components.removeLast()
+        }
+
+        guard !components.isEmpty else {
+            return self.path!
+        }
+
+        let isAbsolutePath = components.first == "/"
+        var result : String = components.removeFirst()
+
+        for component in components {
+            switch component {
+                case ".":
+                    break
+                case ".." where isAbsolutePath:
+                    result = result.bridge().stringByDeletingLastPathComponent
+                default:
+                    result = result.bridge().stringByAppendingPathComponent(component)
+            }
+        }
+
+        if(self.path!.hasSuffix("/")) {
+            result += "/"
+        }
+
+        return result
+    }
 }
 
 // NSURLQueryItem encapsulates a single query name-value pair. The name and value strings of a query name-value pair are not percent encoded. For use with the NSURLComponents queryItems property.
@@ -783,7 +833,7 @@
     }
     
     public func copy(with zone: NSZone? = nil) -> AnyObject {
-        NSUnimplemented()
+        return self
     }
     
     public static func supportsSecureCoding() -> Bool {
diff --git a/Foundation/NSURLResponse.swift b/Foundation/NSURLResponse.swift
index 447ac16..2482706 100644
--- a/Foundation/NSURLResponse.swift
+++ b/Foundation/NSURLResponse.swift
@@ -35,7 +35,7 @@
     }
     
     public func copy(with zone: NSZone? = nil) -> AnyObject {
-        NSUnimplemented()
+        return self
     }
     
     /// Initialize an NSURLResponse with the provided values.
@@ -228,6 +228,21 @@
         default: return "Server Error"
         }
     }
+
+    /// A string that represents the contents of the NSHTTPURLResponse Object.
+    /// This property is intended to produce readable output.
+    override public var description: String {
+        var result = "<\(self.dynamicType) \(unsafeAddress(of: self))> { URL: \(url!.absoluteString) }{ status: \(statusCode), headers {\n"
+        for(key, value) in allHeaderFields {
+            if((key.lowercased() == "content-disposition" && suggestedFilename != "Unknown") || key.lowercased() == "content-type") {
+                result += "   \"\(key)\" = \"\(value)\";\n"
+            } else {
+                result += "   \"\(key)\" = \(value);\n"
+            }
+        }
+        result += "} }"
+        return result
+    }
 }
 
 /// Parses the expected content length from the headers.
diff --git a/Foundation/NSUUID.swift b/Foundation/NSUUID.swift
index 73e8840..9d17245 100644
--- a/Foundation/NSUUID.swift
+++ b/Foundation/NSUUID.swift
@@ -17,14 +17,14 @@
 #endif
 
 public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
-    internal var buffer = UnsafeMutablePointer<UInt8>(allocatingCapacity: 16)
+    internal var buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
     
     public override init() {
         _cf_uuid_generate_random(buffer)
     }
     
     public convenience init?(UUIDString string: String) {
-        let buffer = UnsafeMutablePointer<UInt8>(allocatingCapacity: 16)
+        let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
         if _cf_uuid_parse(string, buffer) != 0 {
             return nil
         }
@@ -40,7 +40,7 @@
     }
     
     public var UUIDString: String {
-        let strPtr = UnsafeMutablePointer<Int8>(allocatingCapacity: 37)
+        let strPtr = UnsafeMutablePointer<Int8>.allocate(capacity: 37)
         _cf_uuid_unparse_upper(buffer, strPtr)
         return String(cString: strPtr)
     }
@@ -66,7 +66,7 @@
 
             guard let data = decodedData else { return nil }
             guard data.count == 16 else { return nil }
-            let buffer = UnsafeMutablePointer<UInt8>(allocatingCapacity: 16)
+            let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
             data.copyBytes(to: buffer, count: 16)
             self.init(UUIDBytes: buffer)
         } else {
diff --git a/Foundation/NSUserDefaults.swift b/Foundation/NSUserDefaults.swift
index 1b4069e..0b5eed9 100644
--- a/Foundation/NSUserDefaults.swift
+++ b/Foundation/NSUserDefaults.swift
@@ -102,24 +102,27 @@
     }
     
     public func stringForKey(_ defaultName: String) -> String? {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSString else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSString else {
             return nil
         }
         return bVal._swiftObject
     }
     public func arrayForKey(_ defaultName: String) -> [AnyObject]? {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSArray else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSArray else {
             return nil
         }
         return bVal._swiftObject
     }
     public func dictionaryForKey(_ defaultName: String) -> [String : AnyObject]? {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSDictionary else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSDictionary else {
             return nil
         }
         //This got out of hand fast...
         let cVal = bVal._swiftObject
-        enum convErr: ErrorProtocol {
+        enum convErr: Swift.Error {
             case convErr
         }
         do {
@@ -141,37 +144,43 @@
         return nil
     }
     public func dataForKey(_ defaultName: String) -> Data? {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? Data else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? Data else {
             return nil
         }
         return bVal
     }
     public func stringArrayForKey(_ defaultName: String) -> [String]? {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSArray else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSArray else {
             return nil
         }
         return _expensivePropertyListConversion(bVal) as? [String]
     }
     public func integerForKey(_ defaultName: String) -> Int {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSNumber else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSNumber else {
             return 0
         }
         return bVal.intValue
     }
     public func floatForKey(_ defaultName: String) -> Float {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSNumber else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSNumber else {
             return 0
         }
         return bVal.floatValue
     }
     public func doubleForKey(_ defaultName: String) -> Double {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSNumber else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSNumber else {
             return 0
         }
         return bVal.doubleValue
     }
     public func boolForKey(_ defaultName: String) -> Bool {
-        guard let aVal = objectForKey(defaultName), bVal = aVal as? NSNumber else {
+        guard let aVal = objectForKey(defaultName),
+              let bVal = aVal as? NSNumber else {
             return false
         }
         return bVal.boolValue
diff --git a/Foundation/NSXMLParser.swift b/Foundation/NSXMLParser.swift
index 2a05574..fc5ff41 100644
--- a/Foundation/NSXMLParser.swift
+++ b/Foundation/NSXMLParser.swift
@@ -90,14 +90,14 @@
         guard let aUrl = a else { break }
         
         var matches: Bool
-        if let aHost = aUrl.host, host = url.host {
+        if let aHost = aUrl.host, let host = url.host {
             matches = host == aHost
         } else {
             return nil
         }
         
         if matches {
-            if let aPort = aUrl.port, port = url.port {
+            if let aPort = aUrl.port, let port = url.port {
                 matches = port == aPort
             } else {
                 return nil
@@ -105,7 +105,7 @@
         }
         
         if matches {
-            if let aScheme = aUrl.scheme, scheme = url.scheme {
+            if let aScheme = aUrl.scheme, let scheme = url.scheme {
                 matches = scheme == aScheme
             } else {
                 return nil
@@ -266,12 +266,13 @@
             }
             let namespaceValueString = namespaces[idx + 1] != nil ? UTF8STRING(namespaces[idx + 1]!) : ""
             if reportNamespaces {
-                if let k = namespaceNameString, v = namespaceValueString {
+                if let k = namespaceNameString, let v = namespaceValueString {
                     nsDict[k] = v
                 }
             }
             if !reportQNameURI {
-                if let k = asAttrNamespaceNameString, v = namespaceValueString {
+                if let k = asAttrNamespaceNameString,
+                   let v = namespaceValueString {
                     attrDict[k] = v
                 }
             }
@@ -460,7 +461,7 @@
     public var allowedExternalEntityURLs: Set<URL>?
     
     internal static func currentParser() -> XMLParser? {
-        if let current = Thread.current().threadDictionary["__CurrentNSXMLParser"] {
+        if let current = Thread.current.threadDictionary["__CurrentNSXMLParser"] {
             return current as? XMLParser
         } else {
             return nil
@@ -469,9 +470,9 @@
     
     internal static func setCurrentParser(_ parser: XMLParser?) {
         if let p = parser {
-            Thread.current().threadDictionary["__CurrentNSXMLParser"] = p
+            Thread.current.threadDictionary["__CurrentNSXMLParser"] = p
         } else {
-            Thread.current().threadDictionary.removeValue(forKey: "__CurrentNSXMLParser")
+            Thread.current.threadDictionary.removeValue(forKey: "__CurrentNSXMLParser")
         }
     }
     
diff --git a/Foundation/String.swift b/Foundation/String.swift
index 053274c..cd45a65 100644
--- a/Foundation/String.swift
+++ b/Foundation/String.swift
@@ -74,7 +74,10 @@
   /// Return an `Index` corresponding to the given offset in our UTF-16
   /// representation.
   func _index(_ utf16Index: Int) -> Index {
-    return Index(_base: String.UnicodeScalarView.Index(utf16Index, _core))
+    return Index(
+      _base: String.UnicodeScalarView.Index(_position: utf16Index),
+      in: characters
+    )
   }
 
   /// Return a `Range<Index>` corresponding to the given `NSRange` of
@@ -160,7 +163,7 @@
   public static func localizedStringWithFormat(
     _ format: String, _ arguments: CVarArg...
   ) -> String {
-    return String(format: format, locale: Locale.currentLocale(),
+    return String(format: format, locale: Locale.current,
       arguments: arguments)
   }
 
@@ -1473,7 +1476,7 @@
   ///       locale: Locale.current()) != nil
   public func localizedCaseInsensitiveContains(_ other: String) -> Bool {
     let r = self.range(
-      of: other, options: .caseInsensitive, locale: Locale.currentLocale()
+      of: other, options: .caseInsensitive, locale: Locale.current
     ) != nil
     _sanityCheck(r == _ns.localizedCaseInsensitiveContains(other))
     return r
diff --git a/Foundation/Unit.swift b/Foundation/Unit.swift
index a088459..e8c6700 100644
--- a/Foundation/Unit.swift
+++ b/Foundation/Unit.swift
@@ -20,7 +20,9 @@
      @param value Value in terms of the unit class
      @return Value in terms of the base unit
      */
-    public func baseUnitValue(fromValue value: Double) -> Double { NSUnimplemented() }
+    public func baseUnitValue(fromValue value: Double) -> Double {
+        return value
+    }
     
     
     /*
@@ -28,27 +30,105 @@
      @param baseUnitValue Value in terms of the base unit
      @return Value in terms of the unit class
      */
-    public func value(fromBaseUnitValue baseUnitValue: Double) -> Double { NSUnimplemented() }
+    public func value(fromBaseUnitValue baseUnitValue: Double) -> Double {
+        return baseUnitValue
+    }
 }
 
 public class UnitConverterLinear : UnitConverter, NSSecureCoding {
     
     
-    public var coefficient: Double { get { NSUnimplemented() } }
+    public private(set) var coefficient: Double
     
-    public var constant: Double { get { NSUnimplemented() } }
+    public private(set) var constant: Double
     
     
-    public convenience init(coefficient: Double) { NSUnimplemented() }
+    public convenience init(coefficient: Double) {
+        self.init(coefficient: coefficient, constant: 0)
+    }
     
     
-    public init(coefficient: Double, constant: Double) { NSUnimplemented() }
+    public init(coefficient: Double, constant: Double) {
+        self.coefficient = coefficient
+        self.constant = constant
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public override func baseUnitValue(fromValue value: Double) -> Double {
+        return value * coefficient + constant
+    }
+    
+    public override func value(fromBaseUnitValue baseUnitValue: Double) -> Double {
+        return (baseUnitValue - constant) / coefficient
+    }
+    
+    public required convenience init?(coder aDecoder: NSCoder) {
+        if aDecoder.allowsKeyedCoding {
+            let coefficient = aDecoder.decodeDouble(forKey: "NS.coefficient")
+            let constant = aDecoder.decodeDouble(forKey: "NS.constant")
+            self.init(coefficient: coefficient, constant: constant)
+        } else {
+            guard
+                let coefficient = aDecoder.decodeObject() as? Double,
+                let constant = aDecoder.decodeObject() as? Double
+                else { return nil }
+            self.init(coefficient: coefficient, constant: constant)
+        }
+    }
+    
+    public func encode(with aCoder: NSCoder) {
+        if aCoder.allowsKeyedCoding {
+            aCoder.encode(self.coefficient, forKey:"NS.coefficient")
+            aCoder.encode(self.constant, forKey:"NS.constant")
+        } else {
+            aCoder.encode(NSNumber(value: self.coefficient))
+            aCoder.encode(NSNumber(value: self.constant))
+        }
+    }
+    
     public static func supportsSecureCoding() -> Bool { return true }
 }
 
+private class UnitConverterReciprocal : UnitConverter, NSSecureCoding {
+    
+    
+    private private(set) var reciprocal: Double
+    
+    
+    private init(reciprocal: Double) {
+        self.reciprocal = reciprocal
+    }
+    
+    private override func baseUnitValue(fromValue value: Double) -> Double {
+        return reciprocal / value
+    }
+    
+    private override func value(fromBaseUnitValue baseUnitValue: Double) -> Double {
+        return reciprocal / baseUnitValue
+    }
+    
+    private required convenience init?(coder aDecoder: NSCoder) {
+        if aDecoder.allowsKeyedCoding {
+            let reciprocal = aDecoder.decodeDouble(forKey: "NS.reciprocal")
+            self.init(reciprocal: reciprocal)
+        } else {
+            guard
+                let reciprocal = aDecoder.decodeObject() as? Double
+                else { return nil }
+            self.init(reciprocal: reciprocal)
+        }
+    }
+    
+    private func encode(with aCoder: NSCoder) {
+        if aCoder.allowsKeyedCoding {
+            aCoder.encode(self.reciprocal, forKey:"NS.reciprocal")
+        } else {
+            aCoder.encode(NSNumber(value: self.reciprocal))
+        }
+    }
+    
+    private static func supportsSecureCoding() -> Bool { return true }
+}
+
 /*
  NSUnit is the base class for all unit types (dimensional and dimensionless).
  */
@@ -67,62 +147,191 @@
         return self
     }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public required init?(coder aDecoder: NSCoder) {
+        if aDecoder.allowsKeyedCoding {
+            guard let symbol = aDecoder.decodeObject(forKey: "NS.symbol") as? String
+                else { return nil }
+            self.symbol = symbol
+        } else {
+            guard let symbol = aDecoder.decodeObject() as? String
+                else { return nil }
+            self.symbol = symbol
+        }
+    }
+    
+    public func encode(with aCoder: NSCoder) {
+        if aCoder.allowsKeyedCoding {
+            aCoder.encode(self.symbol.bridge(), forKey:"NS.symbol")
+        } else {
+            aCoder.encode(self.symbol.bridge())
+        }
+    }
+
     public static func supportsSecureCoding() -> Bool { return true }
 }
 
 public class Dimension : Unit {
     
     
-    public var converter: UnitConverter { get { NSUnimplemented() } }
+    public private(set) var converter: UnitConverter
     
     
-    public init(symbol: String, converter: UnitConverter) { NSUnimplemented() }
+    public init(symbol: String, converter: UnitConverter) {
+        self.converter = converter
+        super.init(symbol: symbol)
+    }
     
     /*
      This class method returns an instance of the dimension class that represents the base unit of that dimension.
      e.g.
      NSUnitSpeed *metersPerSecond = [NSUnitSpeed baseUnit];
      */
-    public class func baseUnit() -> Self { NSUnimplemented() }
+    public class func baseUnit() -> Self {
+        fatalError("*** You must override baseUnit in your class to define its base unit.")
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public required init?(coder aDecoder: NSCoder) {
+        if aDecoder.allowsKeyedCoding {
+            guard
+                let symbol = aDecoder.decodeObject(forKey: "NS.symbol") as? String,
+                let converter = aDecoder.decodeObject(forKey: "NS.converter") as? UnitConverter
+                else { return nil }
+            self.converter = converter
+            super.init(symbol: symbol)
+        } else {
+            guard
+                let symbol = aDecoder.decodeObject() as? String,
+                let converter = aDecoder.decodeObject() as? UnitConverter
+                else { return nil }
+            self.converter = converter
+            super.init(symbol: symbol)
+        }
+    }
+    
+    public override func encode(with aCoder: NSCoder) {
+        super.encode(with: aCoder)
+        
+        if aCoder.allowsKeyedCoding {
+            aCoder.encode(self.converter, forKey:"converter")
+        } else {
+            aCoder.encode(self.converter)
+        }
+    }
 }
 
 public class UnitAcceleration : Dimension {
     
+    /*
+     Base unit - metersPerSecondSquared
+     */
     
-    public class var metersPerSecondSquared: UnitAcceleration { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let metersPerSecondSquared   = "m/s²"
+        static let gravity                  = "g"
+    }
     
-    public class var gravity: UnitAcceleration { get { NSUnimplemented() } }
-
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    private struct Coefficient {
+        static let metersPerSecondSquared   = 1.0
+        static let gravity                  = 9.81
+    }
+    
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
+    
+    public class var metersPerSecondSquared: UnitAcceleration {
+        get {
+            return UnitAcceleration(symbol: Symbol.metersPerSecondSquared, coefficient: Coefficient.metersPerSecondSquared)
+        }
+    }
+    
+    public class var gravity: UnitAcceleration {
+        get {
+            return UnitAcceleration(symbol: Symbol.gravity, coefficient: Coefficient.gravity)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitAcceleration {
+        return UnitAcceleration.metersPerSecondSquared
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitAngle : Dimension {
     
+    /*
+     Base unit - degrees
+     */
     
-    public class var degrees: UnitAngle { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let degrees      = "°"
+        static let arcMinutes   = "ʹ"
+        static let arcSeconds   = "ʹʹ"
+        static let radians      = "rad"
+        static let gradians     = "grad"
+        static let revolutions  = "rev"
+    }
     
-    public class var arcMinutes: UnitAngle { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let degrees      = 1.0
+        static let arcMinutes   = 0.016667
+        static let arcSeconds   = 0.00027778
+        static let radians      = 57.2958
+        static let gradians     = 0.9
+        static let revolutions  = 6.28319
+    }
     
-    public class var arcSeconds: UnitAngle { get { NSUnimplemented() } }
-    
-    public class var radians: UnitAngle { get { NSUnimplemented() } }
-    
-    public class var gradians: UnitAngle { get { NSUnimplemented() } }
-    
-    public class var revolutions: UnitAngle { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
     
-
-    public class var degree: UnitAngle { get { NSUnimplemented() } }
+    public class var degrees: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.degrees, coefficient: Coefficient.degrees)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var arcMinutes: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.arcMinutes, coefficient: Coefficient.arcMinutes)
+        }
+    }
+    
+    public class var arcSeconds: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.arcSeconds, coefficient: Coefficient.arcSeconds)
+        }
+    }
+    
+    public class var radians: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.radians, coefficient: Coefficient.radians)
+        }
+    }
+    
+    public class var gradians: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.gradians, coefficient: Coefficient.gradians)
+        }
+    }
+    
+    public class var revolutions: UnitAngle {
+        get {
+            return UnitAngle(symbol: Symbol.revolutions, coefficient: Coefficient.revolutions)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitAngle {
+        return UnitAngle.degrees
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitArea : Dimension {
@@ -131,50 +340,184 @@
      Base unit - squareMeters
      */
     
-    public class var squareMegameters: UnitArea { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let squareMegameters     = "Mm²"
+        static let squareKilometers     = "km²"
+        static let squareMeters         = "m²"
+        static let squareCentimeters    = "cm²"
+        static let squareMillimeters    = "mm²"
+        static let squareMicrometers    = "µm²"
+        static let squareNanometers     = "nm²"
+        static let squareInches         = "in²"
+        static let squareFeet           = "ft²"
+        static let squareYards          = "yd²"
+        static let squareMiles          = "mi²"
+        static let acres                = "ac"
+        static let ares                 = "a"
+        static let hectares             = "ha"
+    }
     
-    public class var squareKilometers: UnitArea { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let squareMegameters     = 1e12
+        static let squareKilometers     = 1e6
+        static let squareMeters         = 1.0
+        static let squareCentimeters    = 1e-4
+        static let squareMillimeters    = 1e-6
+        static let squareMicrometers    = 1e-12
+        static let squareNanometers     = 1e-18
+        static let squareInches         = 0.00064516
+        static let squareFeet           = 0.092903
+        static let squareYards          = 0.836127
+        static let squareMiles          = 2.59e+6
+        static let acres                = 4046.86
+        static let ares                 = 100.0
+        static let hectares             = 10000.0
+    }
     
-    public class var squareMeters: UnitArea { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var squareCentimeters: UnitArea { get { NSUnimplemented() } }
     
-    public class var squareMillimeters: UnitArea { get { NSUnimplemented() } }
+    public class var squareMegameters: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareMegameters, coefficient: Coefficient.squareMegameters)
+        }
+    }
     
-    public class var squareMicrometers: UnitArea { get { NSUnimplemented() } }
+    public class var squareKilometers: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareKilometers, coefficient: Coefficient.squareKilometers)
+        }
+    }
     
-    public class var squareNanometers: UnitArea { get { NSUnimplemented() } }
+    public class var squareMeters: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareMeters, coefficient: Coefficient.squareMeters)
+        }
+    }
     
-    public class var squareInches: UnitArea { get { NSUnimplemented() } }
+    public class var squareCentimeters: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareCentimeters, coefficient: Coefficient.squareCentimeters)
+        }
+    }
     
-    public class var squareFeet: UnitArea { get { NSUnimplemented() } }
+    public class var squareMillimeters: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareMillimeters, coefficient: Coefficient.squareMillimeters)
+        }
+    }
     
-    public class var squareYards: UnitArea { get { NSUnimplemented() } }
+    public class var squareMicrometers: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareMicrometers, coefficient: Coefficient.squareMicrometers)
+        }
+    }
     
-    public class var squareMiles: UnitArea { get { NSUnimplemented() } }
+    public class var squareNanometers: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareNanometers, coefficient: Coefficient.squareNanometers)
+        }
+    }
     
-    public class var acres: UnitArea { get { NSUnimplemented() } }
+    public class var squareInches: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareInches, coefficient: Coefficient.squareInches)
+        }
+    }
     
-    public class var ares: UnitArea { get { NSUnimplemented() } }
+    public class var squareFeet: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareFeet, coefficient: Coefficient.squareFeet)
+        }
+    }
     
-    public class var hectares: UnitArea { get { NSUnimplemented() } }
+    public class var squareYards: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareYards, coefficient: Coefficient.squareYards)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var squareMiles: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.squareMiles, coefficient: Coefficient.squareMiles)
+        }
+    }
+    
+    public class var acres: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.acres, coefficient: Coefficient.acres)
+        }
+    }
+    
+    public class var ares: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.ares, coefficient: Coefficient.ares)
+        }
+    }
+    
+    public class var hectares: UnitArea {
+        get {
+            return UnitArea(symbol: Symbol.hectares, coefficient: Coefficient.hectares)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitArea {
+        return UnitArea.squareMeters
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitConcentrationMass : Dimension {
     
+    /*
+     Base unit - gramsPerLiter
+     */
     
-    public class var gramsPerLiter: UnitConcentrationMass { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let gramsPerLiter            = "g/L"
+        static let milligramsPerDeciliter   = "mg/dL"
+        static let millimolesPerLiter       = "mmol/L"
+    }
     
-    public class var milligramsPerDeciliter: UnitConcentrationMass { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let gramsPerLiter            = 1.0
+        static let milligramsPerDeciliter   = 0.01
+        static let millimolesPerLiter       = 18.0
+    }
+    
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
     
-    public class func millimolesPerLiter(withGramsPerMole gramsPerMole: Double) -> UnitConcentrationMass { NSUnimplemented() }
+    public class var gramsPerLiter: UnitConcentrationMass {
+        get {
+            return UnitConcentrationMass(symbol: Symbol.gramsPerLiter, coefficient: Coefficient.gramsPerLiter)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var milligramsPerDeciliter: UnitConcentrationMass {
+        get {
+            return UnitConcentrationMass(symbol: Symbol.milligramsPerDeciliter, coefficient: Coefficient.milligramsPerDeciliter)
+        }
+    }
+    
+    public class func millimolesPerLiter(withGramsPerMole gramsPerMole: Double) -> UnitConcentrationMass {
+        return UnitConcentrationMass(symbol: Symbol.millimolesPerLiter, coefficient: Coefficient.millimolesPerLiter * gramsPerMole)
+    }
+    
+    public override class func baseUnit() -> UnitConcentrationMass {
+        return UnitConcentrationMass.gramsPerLiter
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitDispersion : Dimension {
@@ -182,10 +525,33 @@
     /*
      Base unit - partsPerMillion
      */
-    public class var partsPerMillion: UnitDispersion { get { NSUnimplemented() } }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    private struct Symbol {
+        static let partsPerMillion  = "ppm"
+    }
+    
+    private struct Coefficient {
+        static let partsPerMillion  = 1.0
+    }
+    
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
+    
+    
+    public class var partsPerMillion: UnitDispersion {
+        get {
+            return UnitDispersion(symbol: Symbol.partsPerMillion, coefficient: Coefficient.partsPerMillion)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitDispersion {
+        return UnitDispersion.partsPerMillion
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitDuration : Dimension {
@@ -194,33 +560,120 @@
      Base unit - seconds
      */
     
-    public class var seconds: UnitDuration { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let seconds  = "s"
+        static let minutes  = "m"
+        static let hours    = "h"
+    }
     
-    public class var minutes: UnitDuration { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let seconds  = 1.0
+        static let minutes  = 60.0
+        static let hours    = 3600.0
+    }
     
-    public class var hours: UnitDuration { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var seconds: UnitDuration {
+        get {
+            return UnitDuration(symbol: Symbol.seconds, coefficient: Coefficient.seconds)
+        }
+    }
+    
+    public class var minutes: UnitDuration {
+        get {
+            return UnitDuration(symbol: Symbol.minutes, coefficient: Coefficient.minutes)
+        }
+    }
+    
+    public class var hours: UnitDuration {
+        get {
+            return UnitDuration(symbol: Symbol.hours, coefficient: Coefficient.hours)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitDuration {
+        return UnitDuration.seconds
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitElectricCharge : Dimension {
+    /*
+     Base unit - coulombs
+     */
+    
+    private struct Symbol {
+        static let coulombs         = "C"
+        static let megaampereHours  = "MAh"
+        static let kiloampereHours  = "kAh"
+        static let ampereHours      = "Ah"
+        static let milliampereHours = "mAh"
+        static let microampereHours = "µAh"
+    }
+    
+    private struct Coefficient {
+        static let coulombs         = 1.0
+        static let megaampereHours  = 3.6e9
+        static let kiloampereHours  = 3600000.0
+        static let ampereHours      = 3600.0
+        static let milliampereHours = 3.6
+        static let microampereHours = 0.0036
+    }
+    
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
     
-    public class var coulombs: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var coulombs: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.coulombs, coefficient: Coefficient.coulombs)
+        }
+    }
     
-    public class var megaampereHours: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var megaampereHours: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.megaampereHours, coefficient: Coefficient.megaampereHours)
+        }
+    }
     
-    public class var kiloampereHours: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var kiloampereHours: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.kiloampereHours, coefficient: Coefficient.kiloampereHours)
+        }
+    }
     
-    public class var ampereHours: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var ampereHours: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.ampereHours, coefficient: Coefficient.ampereHours)
+        }
+    }
     
-    public class var milliampereHours: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var milliampereHours: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.milliampereHours, coefficient: Coefficient.milliampereHours)
+        }
+    }
     
-    public class var microampereHours: UnitElectricCharge { get { NSUnimplemented() } }
+    public class var microampereHours: UnitElectricCharge {
+        get {
+            return UnitElectricCharge(symbol: Symbol.microampereHours, coefficient: Coefficient.microampereHours)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public override class func baseUnit() -> UnitElectricCharge {
+        return UnitElectricCharge.coulombs
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitElectricCurrent : Dimension {
@@ -228,19 +681,65 @@
     /*
      Base unit - amperes
      */
+    private struct Symbol {
+        static let megaamperes  = "MA"
+        static let kiloamperes  = "kA"
+        static let amperes      = "A"
+        static let milliamperes = "mA"
+        static let microamperes = "µA"
+    }
     
-    public class var megaamperes: UnitElectricCurrent { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let megaamperes  = 1e6
+        static let kiloamperes  = 1e3
+        static let amperes      = 1.0
+        static let milliamperes = 1e-3
+        static let microamperes = 1e-6
+        
+    }
     
-    public class var kiloamperes: UnitElectricCurrent { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var amperes: UnitElectricCurrent { get { NSUnimplemented() } }
     
-    public class var milliamperes: UnitElectricCurrent { get { NSUnimplemented() } }
+    public class var megaamperes: UnitElectricCurrent {
+        get {
+            return UnitElectricCurrent(symbol: Symbol.megaamperes, coefficient: Coefficient.megaamperes)
+        }
+    }
     
-    public class var microamperes: UnitElectricCurrent { get { NSUnimplemented() } }
+    public class var kiloamperes: UnitElectricCurrent {
+        get {
+            return UnitElectricCurrent(symbol: Symbol.kiloamperes, coefficient: Coefficient.kiloamperes)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var amperes: UnitElectricCurrent {
+        get {
+            return UnitElectricCurrent(symbol: Symbol.amperes, coefficient: Coefficient.amperes)
+        }
+    }
+    
+    public class var milliamperes: UnitElectricCurrent {
+        get {
+            return UnitElectricCurrent(symbol: Symbol.milliamperes, coefficient: Coefficient.milliamperes)
+        }
+    }
+    
+    public class var microamperes: UnitElectricCurrent {
+        get {
+            return UnitElectricCurrent(symbol: Symbol.microamperes, coefficient: Coefficient.microamperes)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitElectricCurrent {
+        return UnitElectricCurrent.amperes
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitElectricPotentialDifference : Dimension {
@@ -249,18 +748,65 @@
      Base unit - volts
      */
     
-    public class var megavolts: UnitElectricPotentialDifference { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let megavolts  = "MV"
+        static let kilovolts  = "kV"
+        static let volts      = "V"
+        static let millivolts = "mV"
+        static let microvolts = "µV"
+    }
     
-    public class var kilovolts: UnitElectricPotentialDifference { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let megavolts  = 1e6
+        static let kilovolts  = 1e3
+        static let volts      = 1.0
+        static let millivolts = 1e-3
+        static let microvolts = 1e-6
+        
+    }
     
-    public class var volts: UnitElectricPotentialDifference { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var millivolts: UnitElectricPotentialDifference { get { NSUnimplemented() } }
     
-    public class var microvolts: UnitElectricPotentialDifference { get { NSUnimplemented() } }
+    public class var megavolts: UnitElectricPotentialDifference {
+        get {
+            return UnitElectricPotentialDifference(symbol: Symbol.megavolts, coefficient: Coefficient.megavolts)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var kilovolts: UnitElectricPotentialDifference {
+        get {
+            return UnitElectricPotentialDifference(symbol: Symbol.kilovolts, coefficient: Coefficient.kilovolts)
+        }
+    }
+    
+    public class var volts: UnitElectricPotentialDifference {
+        get {
+            return UnitElectricPotentialDifference(symbol: Symbol.volts, coefficient: Coefficient.volts)
+        }
+    }
+    
+    public class var millivolts: UnitElectricPotentialDifference {
+        get {
+            return UnitElectricPotentialDifference(symbol: Symbol.millivolts, coefficient: Coefficient.millivolts)
+        }
+    }
+    
+    public class var microvolts: UnitElectricPotentialDifference {
+        get {
+            return UnitElectricPotentialDifference(symbol: Symbol.microvolts, coefficient: Coefficient.microvolts)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitElectricPotentialDifference {
+        return UnitElectricPotentialDifference.volts
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitElectricResistance : Dimension {
@@ -269,18 +815,64 @@
      Base unit - ohms
      */
     
-    public class var megaohms: UnitElectricResistance { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let megaohms  = "MΩ"
+        static let kiloohms  = "kΩ"
+        static let ohms      = "Ω"
+        static let milliohms = "mΩ"
+        static let microohms = "µâ„¦"
+    }
     
-    public class var kiloohms: UnitElectricResistance { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let megaohms  = 1e6
+        static let kiloohms  = 1e3
+        static let ohms      = 1.0
+        static let milliohms = 1e-3
+        static let microohms = 1e-6
+        
+    }
     
-    public class var ohms: UnitElectricResistance { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var milliohms: UnitElectricResistance { get { NSUnimplemented() } }
+    public class var megaohms: UnitElectricResistance {
+        get {
+            return UnitElectricResistance(symbol: Symbol.megaohms, coefficient: Coefficient.megaohms)
+        }
+    }
     
-    public class var microohms: UnitElectricResistance { get { NSUnimplemented() } }
+    public class var kiloohms: UnitElectricResistance {
+        get {
+            return UnitElectricResistance(symbol: Symbol.kiloohms, coefficient: Coefficient.kiloohms)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var ohms: UnitElectricResistance {
+        get {
+            return UnitElectricResistance(symbol: Symbol.ohms, coefficient: Coefficient.ohms)
+        }
+    }
+    
+    public class var milliohms: UnitElectricResistance {
+        get {
+            return UnitElectricResistance(symbol: Symbol.milliohms, coefficient: Coefficient.milliohms)
+        }
+    }
+    
+    public class var microohms: UnitElectricResistance {
+        get {
+            return UnitElectricResistance(symbol: Symbol.microohms, coefficient: Coefficient.microohms)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitElectricResistance {
+        return UnitElectricResistance.ohms
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitEnergy : Dimension {
@@ -289,41 +881,154 @@
      Base unit - joules
      */
     
-    public class var kilojoules: UnitEnergy { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let kilojoules       = "kJ"
+        static let joules           = "J"
+        static let kilocalories     = "kCal"
+        static let calories         = "cal"
+        static let kilowattHours    = "kWh"
+    }
     
-    public class var joules: UnitEnergy { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let kilojoules       = 1e3
+        static let joules           = 1.0
+        static let kilocalories     = 4184.0
+        static let calories         = 4.184
+        static let kilowattHours    = 3600000.0
+        
+    }
     
-    public class var kilocalories: UnitEnergy { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var calories: UnitEnergy { get { NSUnimplemented() } }
+    public class var kilojoules: UnitEnergy {
+        get {
+            return UnitEnergy(symbol: Symbol.kilojoules, coefficient: Coefficient.kilojoules)
+        }
+    }
     
-    public class var kilowattHours: UnitEnergy { get { NSUnimplemented() } }
+    public class var joules: UnitEnergy {
+        get {
+            return UnitEnergy(symbol: Symbol.joules, coefficient: Coefficient.joules)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var kilocalories: UnitEnergy {
+        get {
+            return UnitEnergy(symbol: Symbol.kilocalories, coefficient: Coefficient.kilocalories)
+        }
+    }
+    
+    public class var calories: UnitEnergy {
+        get {
+            return UnitEnergy(symbol: Symbol.calories, coefficient: Coefficient.calories)
+        }
+    }
+    
+    public class var kilowattHours: UnitEnergy {
+        get {
+            return UnitEnergy(symbol: Symbol.kilowattHours, coefficient: Coefficient.kilowattHours)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitEnergy {
+        return UnitEnergy.joules
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitFrequency : Dimension {
     
+    /*
+     Base unit - hertz
+     */
     
-    public class var terahertz: UnitFrequency { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let terahertz    = "THz"
+        static let gigahertz    = "GHz"
+        static let megahertz    = "MHz"
+        static let kilohertz    = "kHz"
+        static let hertz        = "Hz"
+        static let millihertz   = "mHz"
+        static let microhertz   = "µHz"
+        static let nanohertz    = "nHz"
+    }
     
-    public class var gigahertz: UnitFrequency { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let terahertz    = 1e12
+        static let gigahertz    = 1e9
+        static let megahertz    = 1e6
+        static let kilohertz    = 1e3
+        static let hertz        = 1.0
+        static let millihertz   = 1e-3
+        static let microhertz   = 1e-6
+        static let nanohertz    = 1e-9
+    }
     
-    public class var megahertz: UnitFrequency { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var kilohertz: UnitFrequency { get { NSUnimplemented() } }
     
-    public class var hertz: UnitFrequency { get { NSUnimplemented() } }
+    public class var terahertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.terahertz, coefficient: Coefficient.terahertz)
+        }
+    }
     
-    public class var millihertz: UnitFrequency { get { NSUnimplemented() } }
+    public class var gigahertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.gigahertz, coefficient: Coefficient.gigahertz)
+        }
+    }
     
-    public class var microhertz: UnitFrequency { get { NSUnimplemented() } }
+    public class var megahertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.megahertz, coefficient: Coefficient.megahertz)
+        }
+    }
     
-    public class var nanohertz: UnitFrequency { get { NSUnimplemented() } }
+    public class var kilohertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.kilohertz, coefficient: Coefficient.kilohertz)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var hertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.hertz, coefficient: Coefficient.hertz)
+        }
+    }
+    
+    public class var millihertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.millihertz, coefficient: Coefficient.millihertz)
+        }
+    }
+    
+    public class var microhertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.microhertz, coefficient: Coefficient.microhertz)
+        }
+    }
+    
+    public class var nanohertz: UnitFrequency {
+        get {
+            return UnitFrequency(symbol: Symbol.nanohertz, coefficient: Coefficient.nanohertz)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitFrequency {
+        return UnitFrequency.hertz
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitFuelEfficiency : Dimension {
@@ -332,14 +1037,48 @@
      Base unit - litersPer100Kilometers
      */
     
-    public class var litersPer100Kilometers: UnitFuelEfficiency { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let litersPer100Kilometers   = "L/100km"
+        static let milesPerImperialGallon   = "mpg"
+        static let milesPerGallon           = "mpg"
+    }
     
-    public class var milesPerImperialGallon: UnitFuelEfficiency { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let litersPer100Kilometers   = 1.0
+        static let milesPerImperialGallon   = 282.481
+        static let milesPerGallon           = 235.215
+    }
     
-    public class var milesPerGallon: UnitFuelEfficiency { get { NSUnimplemented() } }
+    private init(symbol: String, reciprocal: Double) {
+        super.init(symbol: symbol, converter: UnitConverterReciprocal(reciprocal: reciprocal))
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    
+    public class var litersPer100Kilometers: UnitFuelEfficiency {
+        get {
+            return UnitFuelEfficiency(symbol: Symbol.litersPer100Kilometers, reciprocal: Coefficient.litersPer100Kilometers)
+        }
+    }
+    
+    public class var milesPerImperialGallon: UnitFuelEfficiency {
+        get {
+            return UnitFuelEfficiency(symbol: Symbol.milesPerImperialGallon, reciprocal: Coefficient.milesPerImperialGallon)
+        }
+    }
+    
+    public class var milesPerGallon: UnitFuelEfficiency {
+        get {
+            return UnitFuelEfficiency(symbol: Symbol.milesPerGallon, reciprocal: Coefficient.milesPerGallon)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitFuelEfficiency {
+        return UnitFuelEfficiency.litersPer100Kilometers
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitLength : Dimension {
@@ -348,52 +1087,199 @@
      Base unit - meters
      */
     
-    public class var megameters: UnitLength { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let megameters           = "Mm"
+        static let kilometers           = "km"
+        static let hectometers          = "hm"
+        static let decameters           = "dam"
+        static let meters               = "m"
+        static let decimeters           = "dm"
+        static let centimeters          = "cm"
+        static let millimeters          = "mm"
+        static let micrometers          = "µm"
+        static let nanometers           = "nm"
+        static let picometers           = "pm"
+        static let inches               = "in"
+        static let feet                 = "ft"
+        static let yards                = "yd"
+        static let miles                = "mi"
+        static let scandinavianMiles    = "smi"
+        static let lightyears           = "ly"
+        static let nauticalMiles        = "NM"
+        static let fathoms              = "ftm"
+        static let furlongs             = "fur"
+        static let astronomicalUnits    = "ua"
+        static let parsecs              = "pc"
+    }
     
-    public class var kilometers: UnitLength { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let megameters           = 1e6
+        static let kilometers           = 1e3
+        static let hectometers          = 1e2
+        static let decameters           = 1e1
+        static let meters               = 1.0
+        static let decimeters           = 1e-1
+        static let centimeters          = 1e-2
+        static let millimeters          = 1e-3
+        static let micrometers          = 1e-6
+        static let nanometers           = 1e-9
+        static let picometers           = 1e-12
+        static let inches               = 0.0254
+        static let feet                 = 0.3048
+        static let yards                = 0.9144
+        static let miles                = 1609.34
+        static let scandinavianMiles    = 10000.0
+        static let lightyears           = 9.461e+15
+        static let nauticalMiles        = 1852.0
+        static let fathoms              = 1.8288
+        static let furlongs             = 201.168
+        static let astronomicalUnits    = 1.496e+11
+        static let parsecs              = 3.086e+16
+    }
     
-    public class var hectometers: UnitLength { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var decameters: UnitLength { get { NSUnimplemented() } }
+    public class var megameters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.megameters, coefficient: Coefficient.megameters)
+        }
+    }
     
-    public class var meters: UnitLength { get { NSUnimplemented() } }
+    public class var kilometers: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.kilometers, coefficient: Coefficient.kilometers)
+        }
+    }
     
-    public class var decimeters: UnitLength { get { NSUnimplemented() } }
+    public class var hectometers: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.hectometers, coefficient: Coefficient.hectometers)
+        }
+    }
     
-    public class var centimeters: UnitLength { get { NSUnimplemented() } }
+    public class var decameters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.decameters, coefficient: Coefficient.decameters)
+        }
+    }
     
-    public class var millimeters: UnitLength { get { NSUnimplemented() } }
+    public class var meters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.meters, coefficient: Coefficient.meters)
+        }
+    }
     
-    public class var micrometers: UnitLength { get { NSUnimplemented() } }
+    public class var decimeters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.decimeters, coefficient: Coefficient.decimeters)
+        }
+    }
     
-    public class var nanometers: UnitLength { get { NSUnimplemented() } }
+    public class var centimeters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.centimeters, coefficient: Coefficient.centimeters)
+        }
+    }
     
-    public class var picometers: UnitLength { get { NSUnimplemented() } }
+    public class var millimeters: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.millimeters, coefficient: Coefficient.millimeters)
+        }
+    }
     
-    public class var inches: UnitLength { get { NSUnimplemented() } }
+    public class var micrometers: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.micrometers, coefficient: Coefficient.micrometers)
+        }
+    }
     
-    public class var feet: UnitLength { get { NSUnimplemented() } }
+    public class var nanometers: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.nanometers, coefficient: Coefficient.nanometers)
+        }
+    }
     
-    public class var yards: UnitLength { get { NSUnimplemented() } }
+    public class var picometers: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.picometers, coefficient: Coefficient.picometers)
+        }
+    }
     
-    public class var miles: UnitLength { get { NSUnimplemented() } }
+    public class var inches: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.inches, coefficient: Coefficient.inches)
+        }
+    }
     
-    public class var scandinavianMiles: UnitLength { get { NSUnimplemented() } }
+    public class var feet: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.feet, coefficient: Coefficient.feet)
+        }
+    }
     
-    public class var lightyears: UnitLength { get { NSUnimplemented() } }
+    public class var yards: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.yards, coefficient: Coefficient.yards)
+        }
+    }
     
-    public class var nauticalMiles: UnitLength { get { NSUnimplemented() } }
+    public class var miles: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.miles, coefficient: Coefficient.miles)
+        }
+    }
     
-    public class var fathoms: UnitLength { get { NSUnimplemented() } }
+    public class var scandinavianMiles: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.scandinavianMiles, coefficient: Coefficient.scandinavianMiles)
+        }
+    }
     
-    public class var furlongs: UnitLength { get { NSUnimplemented() } }
+    public class var lightyears: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.lightyears, coefficient: Coefficient.lightyears)
+        }
+    }
     
-    public class var astronomicalUnits: UnitLength { get { NSUnimplemented() } }
+    public class var nauticalMiles: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.nauticalMiles, coefficient: Coefficient.nauticalMiles)
+        }
+    }
     
-    public class var parsecs: UnitLength { get { NSUnimplemented() } }
+    public class var fathoms: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.fathoms, coefficient: Coefficient.fathoms)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var furlongs: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.furlongs, coefficient: Coefficient.furlongs)
+        }
+    }
+    
+    public class var astronomicalUnits: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.astronomicalUnits, coefficient: Coefficient.astronomicalUnits)
+        }
+    }
+    
+    public class var parsecs: UnitLength {
+        get {
+            return UnitLength(symbol: Symbol.parsecs, coefficient: Coefficient.parsecs)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitLength {
+        return UnitLength.meters
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitIlluminance : Dimension {
@@ -402,49 +1288,184 @@
      Base unit - lux
      */
     
-    public class var lux: UnitIlluminance { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let lux   = "lx"
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    private struct Coefficient {
+        static let lux   = 1.0
+    }
+    
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
+    
+    public class var lux: UnitIlluminance {
+        get {
+            return UnitIlluminance(symbol: Symbol.lux, coefficient: Coefficient.lux)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitIlluminance {
+        return UnitIlluminance.lux
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitMass : Dimension {
     
+    /*
+     Base unit - kilograms
+     */
     
-    public class var kilograms: UnitMass { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let kilograms    = "kg"
+        static let grams        = "g"
+        static let decigrams    = "dg"
+        static let centigrams   = "cg"
+        static let milligrams   = "mg"
+        static let micrograms   = "µg"
+        static let nanograms    = "ng"
+        static let picograms    = "pg"
+        static let ounces       = "oz"
+        static let pounds       = "lb"
+        static let stones       = "st"
+        static let metricTons   = "t"
+        static let shortTons    = "ton"
+        static let carats       = "ct"
+        static let ouncesTroy   = "oz t"
+        static let slugs        = "slug"
+    }
     
-    public class var grams: UnitMass { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let kilograms    = 1.0
+        static let grams        = 1e-3
+        static let decigrams    = 1e-4
+        static let centigrams   = 1e-5
+        static let milligrams   = 1e-6
+        static let micrograms   = 1e-9
+        static let nanograms    = 1e-12
+        static let picograms    = 1e-15
+        static let ounces       = 0.0283495
+        static let pounds       = 0.453592
+        static let stones       = 0.157473
+        static let metricTons   = 1000.0
+        static let shortTons    = 907.185
+        static let carats       = 0.0002
+        static let ouncesTroy   = 0.03110348
+        static let slugs        = 14.5939
+    }
     
-    public class var decigrams: UnitMass { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var centigrams: UnitMass { get { NSUnimplemented() } }
+    public class var kilograms: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.kilograms, coefficient: Coefficient.kilograms)
+        }
+    }
     
-    public class var milligrams: UnitMass { get { NSUnimplemented() } }
+    public class var grams: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.grams, coefficient: Coefficient.grams)
+        }
+    }
     
-    public class var micrograms: UnitMass { get { NSUnimplemented() } }
+    public class var decigrams: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.decigrams, coefficient: Coefficient.decigrams)
+        }
+    }
     
-    public class var nanograms: UnitMass { get { NSUnimplemented() } }
+    public class var centigrams: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.centigrams, coefficient: Coefficient.centigrams)
+        }
+    }
     
-    public class var picograms: UnitMass { get { NSUnimplemented() } }
+    public class var milligrams: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.milligrams, coefficient: Coefficient.milligrams)
+        }
+    }
     
-    public class var ounces: UnitMass { get { NSUnimplemented() } }
+    public class var micrograms: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.micrograms, coefficient: Coefficient.micrograms)
+        }
+    }
     
-    public class var pounds: UnitMass { get { NSUnimplemented() } }
+    public class var nanograms: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.nanograms, coefficient: Coefficient.nanograms)
+        }
+    }
     
-    public class var stones: UnitMass { get { NSUnimplemented() } }
+    public class var picograms: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.picograms, coefficient: Coefficient.picograms)
+        }
+    }
     
-    public class var metricTons: UnitMass { get { NSUnimplemented() } }
+    public class var ounces: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.ounces, coefficient: Coefficient.ounces)
+        }
+    }
     
-    public class var shortTons: UnitMass { get { NSUnimplemented() } }
+    public class var pounds: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.pounds, coefficient: Coefficient.pounds)
+        }
+    }
     
-    public class var carats: UnitMass { get { NSUnimplemented() } }
+    public class var stones: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.stones, coefficient: Coefficient.stones)
+        }
+    }
     
-    public class var ouncesTroy: UnitMass { get { NSUnimplemented() } }
+    public class var metricTons: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.metricTons, coefficient: Coefficient.metricTons)
+        }
+    }
     
-    public class var slugs: UnitMass { get { NSUnimplemented() } }
+    public class var shortTons: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.shortTons, coefficient: Coefficient.shortTons)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var carats: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.carats, coefficient: Coefficient.carats)
+        }
+    }
+    
+    public class var ouncesTroy: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.ouncesTroy, coefficient: Coefficient.ouncesTroy)
+        }
+    }
+    
+    public class var slugs: UnitMass {
+        get {
+            return UnitMass(symbol: Symbol.slugs, coefficient: Coefficient.slugs)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitMass {
+        return UnitMass.kilograms
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitPower : Dimension {
@@ -453,30 +1474,111 @@
      Base unit - watts
      */
     
-    public class var terawatts: UnitPower { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let terawatts  = "TW"
+        static let gigawatts  = "GW"
+        static let megawatts  = "MW"
+        static let kilowatts  = "kW"
+        static let watts      = "W"
+        static let milliwatts = "mW"
+        static let microwatts = "µW"
+        static let nanowatts  = "nW"
+        static let picowatts  = "nW"
+        static let femtowatts = "nHz"
+        static let horsepower = "hp"
+    }
     
-    public class var gigawatts: UnitPower { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let terawatts  = 1e12
+        static let gigawatts  = 1e9
+        static let megawatts  = 1e6
+        static let kilowatts  = 1e3
+        static let watts      = 1.0
+        static let milliwatts = 1e-3
+        static let microwatts = 1e-6
+        static let nanowatts  = 1e-9
+        static let picowatts  = 1e-12
+        static let femtowatts = 1e-15
+        static let horsepower = 745.7
+    }
     
-    public class var megawatts: UnitPower { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var kilowatts: UnitPower { get { NSUnimplemented() } }
+    public class var terawatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.terawatts, coefficient: Coefficient.terawatts)
+        }
+    }
     
-    public class var watts: UnitPower { get { NSUnimplemented() } }
+    public class var gigawatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.gigawatts, coefficient: Coefficient.gigawatts)
+        }
+    }
     
-    public class var milliwatts: UnitPower { get { NSUnimplemented() } }
+    public class var megawatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.megawatts, coefficient: Coefficient.megawatts)
+        }
+    }
     
-    public class var microwatts: UnitPower { get { NSUnimplemented() } }
+    public class var kilowatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.kilowatts, coefficient: Coefficient.kilowatts)
+        }
+    }
     
-    public class var nanowatts: UnitPower { get { NSUnimplemented() } }
+    public class var watts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.watts, coefficient: Coefficient.watts)
+        }
+    }
     
-    public class var picowatts: UnitPower { get { NSUnimplemented() } }
+    public class var milliwatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.milliwatts, coefficient: Coefficient.milliwatts)
+        }
+    }
     
-    public class var femtowatts: UnitPower { get { NSUnimplemented() } }
+    public class var microwatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.microwatts, coefficient: Coefficient.microwatts)
+        }
+    }
     
-    public class var horsepower: UnitPower { get { NSUnimplemented() } }
+    public class var nanowatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.nanowatts, coefficient: Coefficient.nanowatts)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var picowatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.picowatts, coefficient: Coefficient.picowatts)
+        }
+    }
+    
+    public class var femtowatts: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.femtowatts, coefficient: Coefficient.femtowatts)
+        }
+    }
+    
+    public class var horsepower: UnitPower {
+        get {
+            return UnitPower(symbol: Symbol.horsepower, coefficient: Coefficient.horsepower)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitPower {
+        return UnitPower.watts
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitPressure : Dimension {
@@ -485,28 +1587,104 @@
      Base unit - newtonsPerMetersSquared (equivalent to 1 pascal)
      */
     
-    public class var newtonsPerMetersSquared: UnitPressure { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let newtonsPerMetersSquared  = "N/m²"
+        static let gigapascals              = "GPa"
+        static let megapascals              = "MPa"
+        static let kilopascals              = "kPa"
+        static let hectopascals             = "hPa"
+        static let inchesOfMercury          = "inHg"
+        static let bars                     = "bar"
+        static let millibars                = "mbar"
+        static let millimetersOfMercury     = "mmHg"
+        static let poundsForcePerSquareInch = "psi"
+    }
     
-    public class var gigapascals: UnitPressure { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let newtonsPerMetersSquared  = 1.0
+        static let gigapascals              = 1e9
+        static let megapascals              = 1e6
+        static let kilopascals              = 1e3
+        static let hectopascals             = 1e2
+        static let inchesOfMercury          = 3386.39
+        static let bars                     = 1e5
+        static let millibars                = 1e2
+        static let millimetersOfMercury     = 133.322
+        static let poundsForcePerSquareInch = 6894.76
+    }
     
-    public class var megapascals: UnitPressure { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var kilopascals: UnitPressure { get { NSUnimplemented() } }
     
-    public class var hectopascals: UnitPressure { get { NSUnimplemented() } }
+    public class var newtonsPerMetersSquared: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.newtonsPerMetersSquared, coefficient: Coefficient.newtonsPerMetersSquared)
+        }
+    }
     
-    public class var inchesOfMercury: UnitPressure { get { NSUnimplemented() } }
+    public class var gigapascals: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.gigapascals, coefficient: Coefficient.gigapascals)
+        }
+    }
     
-    public class var bars: UnitPressure { get { NSUnimplemented() } }
+    public class var megapascals: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.megapascals, coefficient: Coefficient.megapascals)
+        }
+    }
     
-    public class var millibars: UnitPressure { get { NSUnimplemented() } }
+    public class var kilopascals: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.kilopascals, coefficient: Coefficient.kilopascals)
+        }
+    }
     
-    public class var millimetersOfMercury: UnitPressure { get { NSUnimplemented() } }
+    public class var hectopascals: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.hectopascals, coefficient: Coefficient.hectopascals)
+        }
+    }
     
-    public class var poundsForcePerSquareInch: UnitPressure { get { NSUnimplemented() } }
+    public class var inchesOfMercury: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.inchesOfMercury, coefficient: Coefficient.inchesOfMercury)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var bars: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.bars, coefficient: Coefficient.bars)
+        }
+    }
+    
+    public class var millibars: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.millibars, coefficient: Coefficient.millibars)
+        }
+    }
+    
+    public class var millimetersOfMercury: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.millimetersOfMercury, coefficient: Coefficient.millimetersOfMercury)
+        }
+    }
+    
+    public class var poundsForcePerSquareInch: UnitPressure {
+        get {
+            return UnitPressure(symbol: Symbol.poundsForcePerSquareInch, coefficient: Coefficient.poundsForcePerSquareInch)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitPressure {
+        return UnitPressure.newtonsPerMetersSquared
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitSpeed : Dimension {
@@ -515,16 +1693,56 @@
      Base unit - metersPerSecond
      */
     
-    public class var metersPerSecond: UnitSpeed { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let metersPerSecond      = "m/s"
+        static let kilometersPerHour    = "km/h"
+        static let milesPerHour         = "mph"
+        static let knots                = "kn"
+    }
     
-    public class var kilometersPerHour: UnitSpeed { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let metersPerSecond      = 1.0
+        static let kilometersPerHour    = 0.277778
+        static let milesPerHour         = 0.44704
+        static let knots                = 0.514444
+    }
     
-    public class var milesPerHour: UnitSpeed { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var knots: UnitSpeed { get { NSUnimplemented() } }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var metersPerSecond: UnitSpeed {
+        get {
+            return UnitSpeed(symbol: Symbol.metersPerSecond, coefficient: Coefficient.metersPerSecond)
+        }
+    }
+    
+    public class var kilometersPerHour: UnitSpeed {
+        get {
+            return UnitSpeed(symbol: Symbol.kilometersPerHour, coefficient: Coefficient.kilometersPerHour)
+        }
+    }
+    
+    public class var milesPerHour: UnitSpeed {
+        get {
+            return UnitSpeed(symbol: Symbol.milesPerHour, coefficient: Coefficient.milesPerHour)
+        }
+    }
+    
+    public class var knots: UnitSpeed {
+        get {
+            return UnitSpeed(symbol: Symbol.knots, coefficient: Coefficient.knots)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitSpeed {
+        return UnitSpeed.metersPerSecond
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitTemperature : Dimension {
@@ -532,81 +1750,325 @@
     /*
      Base unit - kelvin
      */
-    public class var kelvin: UnitTemperature { get { NSUnimplemented() } }
     
-    public class var celsius: UnitTemperature { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let kelvin     = "K"
+        static let celsius    = "°C"
+        static let fahrenheit = "°F"
+    }
     
-    public class var fahrenheit: UnitTemperature { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let kelvin     = 1.0
+        static let celsius    = 1.0
+        static let fahrenheit = 0.55555555555556
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    private struct Constant {
+        static let kelvin     = 0.0
+        static let celsius    = 273.15
+        static let fahrenheit = 255.37222222222427
+    }
+    
+    private init(symbol: String, coefficient: Double, constant: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient, constant: constant))
+    }
+    
+    public class var kelvin: UnitTemperature {
+        get {
+            return UnitTemperature(symbol: Symbol.kelvin, coefficient: Coefficient.kelvin, constant: Constant.kelvin)
+        }
+    }
+    
+    public class var celsius: UnitTemperature {
+        get {
+            return UnitTemperature(symbol: Symbol.celsius, coefficient: Coefficient.celsius, constant: Constant.celsius)
+        }
+    }
+    
+    public class var fahrenheit: UnitTemperature {
+        get {
+            return UnitTemperature(symbol: Symbol.fahrenheit, coefficient: Coefficient.fahrenheit, constant: Constant.fahrenheit)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitTemperature {
+        return UnitTemperature.kelvin
+    }
+    
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
 
 public class UnitVolume : Dimension {
     
+    /*
+     Base unit - liters
+     */
     
-    public class var megaliters: UnitVolume { get { NSUnimplemented() } }
+    private struct Symbol {
+        static let megaliters           = "ML"
+        static let kiloliters           = "kL"
+        static let liters               = "L"
+        static let deciliters           = "dl"
+        static let centiliters          = "cL"
+        static let milliliters          = "mL"
+        static let cubicKilometers      = "km³"
+        static let cubicMeters          = "m³"
+        static let cubicDecimeters      = "dm³"
+        static let cubicCentimeters     = "cm³"
+        static let cubicMillimeters     = "mm³"
+        static let cubicInches          = "in³"
+        static let cubicFeet            = "ft³"
+        static let cubicYards           = "yd³"
+        static let cubicMiles           = "mi³"
+        static let acreFeet             = "af"
+        static let bushels              = "bsh"
+        static let teaspoons            = "tsp"
+        static let tablespoons          = "tbsp"
+        static let fluidOunces          = "fl oz"
+        static let cups                 = "cup"
+        static let pints                = "pt"
+        static let quarts               = "qt"
+        static let gallons              = "gal"
+        static let imperialTeaspoons    = "tsp Imperial"
+        static let imperialTablespoons  = "tbsp Imperial"
+        static let imperialFluidOunces  = "fl oz Imperial"
+        static let imperialPints        = "pt Imperial"
+        static let imperialQuarts       = "qt Imperial"
+        static let imperialGallons      = "gal Imperial"
+        static let metricCups           = "metric cup Imperial"
+    }
     
-    public class var kiloliters: UnitVolume { get { NSUnimplemented() } }
+    private struct Coefficient {
+        static let megaliters           = 1e6
+        static let kiloliters           = 1e3
+        static let liters               = 1.0
+        static let deciliters           = 1e-1
+        static let centiliters          = 1e-2
+        static let milliliters          = 1e-3
+        static let cubicKilometers      = 1e12
+        static let cubicMeters          = 1000.0
+        static let cubicDecimeters      = 1.0
+        static let cubicCentimeters     = 0.01
+        static let cubicMillimeters     = 0.001
+        static let cubicInches          = 0.0163871
+        static let cubicFeet            = 28.3168
+        static let cubicYards           = 764.555
+        static let cubicMiles           = 4.168e+12
+        static let acreFeet             = 1.233e+6
+        static let bushels              = 35.2391
+        static let teaspoons            = 0.00492892
+        static let tablespoons          = 0.0147868
+        static let fluidOunces          = 0.0295735
+        static let cups                 = 0.24
+        static let pints                = 0.473176
+        static let quarts               = 0.946353
+        static let gallons              = 3.78541
+        static let imperialTeaspoons    = 0.00591939
+        static let imperialTablespoons  = 0.0177582
+        static let imperialFluidOunces  = 0.0284131
+        static let imperialPints        = 0.568261
+        static let imperialQuarts       = 1.13652
+        static let imperialGallons      = 4.54609
+        static let metricCups           = 0.25
+    }
     
-    public class var liters: UnitVolume { get { NSUnimplemented() } }
+    private init(symbol: String, coefficient: Double) {
+        super.init(symbol: symbol, converter: UnitConverterLinear(coefficient: coefficient))
+    }
     
-    public class var deciliters: UnitVolume { get { NSUnimplemented() } }
     
-    public class var centiliters: UnitVolume { get { NSUnimplemented() } }
+    public class var megaliters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.megaliters, coefficient: Coefficient.megaliters)
+        }
+    }
     
-    public class var milliliters: UnitVolume { get { NSUnimplemented() } }
+    public class var kiloliters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.kiloliters, coefficient: Coefficient.kiloliters)
+        }
+    }
     
-    public class var cubicKilometers: UnitVolume { get { NSUnimplemented() } }
+    public class var liters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.liters, coefficient: Coefficient.liters)
+        }
+    }
     
-    public class var cubicMeters: UnitVolume { get { NSUnimplemented() } }
+    public class var deciliters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.deciliters, coefficient: Coefficient.deciliters)
+        }
+    }
     
-    public class var cubicDecimeters: UnitVolume { get { NSUnimplemented() } }
+    public class var centiliters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.centiliters, coefficient: Coefficient.centiliters)
+        }
+    }
     
-    public class var cubicCentimeters: UnitVolume { get { NSUnimplemented() } }
+    public class var milliliters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.milliliters, coefficient: Coefficient.milliliters)
+        }
+    }
     
-    public class var cubicMillimeters: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicKilometers: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicKilometers, coefficient: Coefficient.cubicKilometers)
+        }
+    }
     
-    public class var cubicInches: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicMeters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicMeters, coefficient: Coefficient.cubicMeters)
+        }
+    }
     
-    public class var cubicFeet: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicDecimeters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicDecimeters, coefficient: Coefficient.cubicDecimeters)
+        }
+    }
     
-    public class var cubicYards: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicCentimeters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicCentimeters, coefficient: Coefficient.cubicCentimeters)
+        }
+    }
     
-    public class var cubicMiles: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicMillimeters: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicMillimeters, coefficient: Coefficient.cubicMillimeters)
+        }
+    }
     
-    public class var acreFeet: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicInches: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicInches, coefficient: Coefficient.cubicInches)
+        }
+    }
     
-    public class var bushels: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicFeet: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicFeet, coefficient: Coefficient.cubicFeet)
+        }
+    }
     
-    public class var teaspoons: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicYards: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicYards, coefficient: Coefficient.cubicYards)
+        }
+    }
     
-    public class var tablespoons: UnitVolume { get { NSUnimplemented() } }
+    public class var cubicMiles: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cubicMiles, coefficient: Coefficient.cubicMiles)
+        }
+    }
     
-    public class var fluidOunces: UnitVolume { get { NSUnimplemented() } }
+    public class var acreFeet: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.acreFeet, coefficient: Coefficient.acreFeet)
+        }
+    }
     
-    public class var cups: UnitVolume { get { NSUnimplemented() } }
+    public class var bushels: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.bushels, coefficient: Coefficient.bushels)
+        }
+    }
     
-    public class var pints: UnitVolume { get { NSUnimplemented() } }
+    public class var teaspoons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.teaspoons, coefficient: Coefficient.teaspoons)
+        }
+    }
     
-    public class var quarts: UnitVolume { get { NSUnimplemented() } }
+    public class var tablespoons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.tablespoons, coefficient: Coefficient.tablespoons)
+        }
+    }
     
-    public class var gallons: UnitVolume { get { NSUnimplemented() } }
+    public class var fluidOunces: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.fluidOunces, coefficient: Coefficient.fluidOunces)
+        }
+    }
     
-    public class var imperialTeaspoons: UnitVolume { get { NSUnimplemented() } }
+    public class var cups: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.cups, coefficient: Coefficient.cups)
+        }
+    }
     
-    public class var imperialTablespoons: UnitVolume { get { NSUnimplemented() } }
+    public class var pints: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.pints, coefficient: Coefficient.pints)
+        }
+    }
     
-    public class var imperialFluidOunces: UnitVolume { get { NSUnimplemented() } }
+    public class var quarts: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.quarts, coefficient: Coefficient.quarts)
+        }
+    }
     
-    public class var imperialPints: UnitVolume { get { NSUnimplemented() } }
+    public class var gallons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.gallons, coefficient: Coefficient.gallons)
+        }
+    }
     
-    public class var imperialQuarts: UnitVolume { get { NSUnimplemented() } }
+    public class var imperialTeaspoons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialTeaspoons, coefficient: Coefficient.imperialTeaspoons)
+        }
+    }
     
-    public class var imperialGallons: UnitVolume { get { NSUnimplemented() } }
+    public class var imperialTablespoons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialTablespoons, coefficient: Coefficient.imperialTablespoons)
+        }
+    }
     
-    public class var metricCups: UnitVolume { get { NSUnimplemented() } }
+    public class var imperialFluidOunces: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialFluidOunces, coefficient: Coefficient.imperialFluidOunces)
+        }
+    }
     
-    public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
-    public override func encode(with aCoder: NSCoder) { NSUnimplemented() }
+    public class var imperialPints: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialPints, coefficient: Coefficient.imperialPints)
+        }
+    }
+    
+    public class var imperialQuarts: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialQuarts, coefficient: Coefficient.imperialQuarts)
+        }
+    }
+    
+    public class var imperialGallons: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.imperialGallons, coefficient: Coefficient.imperialGallons)
+        }
+    }
+    
+    public class var metricCups: UnitVolume {
+        get {
+            return UnitVolume(symbol: Symbol.metricCups, coefficient: Coefficient.metricCups)
+        }
+    }
+    
+    public override class func baseUnit() -> UnitVolume {
+        return UnitVolume.liters
+    }
+    
+    public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) }
+    public override func encode(with aCoder: NSCoder) { super.encode(with: aCoder) }
 }
diff --git a/README.md b/README.md
index a2b2cc5..0e909a3 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
 
 > Important: This project is in the early stages of development. It is not yet ready for production use, but it is ready for contributions. It is scheduled to be part of the Swift 3 release.
 
-This project provides an implementation of the Foundation API for platforms where there is no Objective-C runtime. On OS X, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system. Our goal is to abstract away the exact underlying platform as much as possible.
+This project provides an implementation of the Foundation API for platforms where there is no Objective-C runtime. On macOS, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system. Our goal is to abstract away the exact underlying platform as much as possible.
 
 ## Goals
 
diff --git a/TestFoundation/TestNSCalendar.swift b/TestFoundation/TestNSCalendar.swift
index de24ae0..57d03fd 100644
--- a/TestFoundation/TestNSCalendar.swift
+++ b/TestFoundation/TestNSCalendar.swift
@@ -24,6 +24,7 @@
             ("test_gettingDatesOnHebrewCalendar", test_gettingDatesOnHebrewCalendar ),
             ("test_initializingWithInvalidIdentifier", test_initializingWithInvalidIdentifier),
             ("test_gettingDatesOnChineseCalendar", test_gettingDatesOnChineseCalendar),
+            ("test_copy",test_copy),
             // Disabled because this fails on linux https://bugs.swift.org/browse/SR-320
             // ("test_currentCalendarRRstability", test_currentCalendarRRstability),
         ]
@@ -79,13 +80,28 @@
         XCTAssertNil(calendar)
     }
     
-    func test_currentCalendarRRstability() {
+    func test_currentRRstability() {
         var AMSymbols = [String]()
         for _ in 1...10 {
-            let cal = Calendar.currentCalendar()
+            let cal = Calendar.current
             AMSymbols.append(cal.AMSymbol)
         }
         
         XCTAssertEqual(AMSymbols.count, 10, "Accessing current calendar should work over multiple callouts")
     }
+    
+    func test_copy() {
+        let calendar = Calendar.current
+
+        //Mutate below fields and check if change is being reflected in copy.
+        calendar.firstWeekday = 2 
+        calendar.minimumDaysInFirstWeek = 2
+
+        let copy = calendar.copy() as! Calendar
+        XCTAssertTrue(copy.isEqual(calendar))
+
+        //verify firstWeekday and minimumDaysInFirstWeek of 'copy'. 
+        XCTAssertEqual(copy.firstWeekday, 2)
+        XCTAssertEqual(copy.minimumDaysInFirstWeek, 2)
+    }
 }
diff --git a/TestFoundation/TestNSData.swift b/TestFoundation/TestNSData.swift
index ad03369..b2b84f6 100644
--- a/TestFoundation/TestNSData.swift
+++ b/TestFoundation/TestNSData.swift
@@ -39,7 +39,8 @@
             ("test_initializeWithBase64EncodedStringGetsDecodedData", test_initializeWithBase64EncodedStringGetsDecodedData),
             ("test_base64DecodeWithPadding1", test_base64DecodeWithPadding1),
             ("test_base64DecodeWithPadding2", test_base64DecodeWithPadding2),
-            ("test_rangeOfData",test_rangeOfData)
+            ("test_rangeOfData",test_rangeOfData),
+            ("test_initMutableDataWithLength", test_initMutableDataWithLength)
         ]
     }
     
@@ -338,4 +339,10 @@
         
     }
 
+    func test_initMutableDataWithLength() {
+        let mData = NSMutableData(length: 30)
+        XCTAssertNotNil(mData)
+        XCTAssertEqual(mData!.length, 30)
+    }
+
 }
diff --git a/TestFoundation/TestNSHTTPCookie.swift b/TestFoundation/TestNSHTTPCookie.swift
index 82ef5cc..6e2ee07 100644
--- a/TestFoundation/TestNSHTTPCookie.swift
+++ b/TestFoundation/TestNSHTTPCookie.swift
@@ -158,8 +158,11 @@
         let formatter = DateFormatter()
         formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss O"   
         formatter.timeZone = TimeZone(abbreviation: "GMT") 
-        let expiresDate = formatter.date(from: "Wed, 21 Sep 2016 05:33:00 GMT")!
-        XCTAssertTrue(expiresDate.compare(cookies[0].expiresDate!) == .orderedSame)
+        if let expiresDate = formatter.date(from: "Wed, 21 Sep 2016 05:33:00 GMT") {
+            XCTAssertTrue(expiresDate.compare(cookies[0].expiresDate!) == .orderedSame)
+        } else {
+            XCTFail("Unable to parse the given date from the formatter")
+        }
     }
 
     func test_cookiesWithResponseHeaderNoPathNoDomain() {
diff --git a/TestFoundation/TestNSIndexSet.swift b/TestFoundation/TestNSIndexSet.swift
index e505af3..5dfcfa7 100644
--- a/TestFoundation/TestNSIndexSet.swift
+++ b/TestFoundation/TestNSIndexSet.swift
@@ -25,7 +25,8 @@
             ("test_enumeration", test_enumeration),
             ("test_sequenceType", test_sequenceType),
             ("test_removal", test_removal),
-            ("test_addition",test_addition),
+            ("test_addition", test_addition),
+            ("test_setAlgebra", test_setAlgebra),
         ]
     }
     
@@ -168,4 +169,43 @@
     
     }
     
+    func test_setAlgebra() {
+        
+        var is1, is2, expected: IndexSet
+        
+        do {
+            is1 = IndexSet(integersIn: 0..<5)
+            is2 = IndexSet(integersIn: 3..<10)
+            
+            expected = IndexSet(integersIn: 0..<3)
+            expected.insert(integersIn: 5..<10)
+            
+            XCTAssertTrue(expected == is1.symmetricDifference(is2))
+            XCTAssertTrue(expected == is2.symmetricDifference(is1))
+        }
+        
+        do {
+            is1 = IndexSet([0, 2])
+            is2 = IndexSet([0, 1, 2])
+            XCTAssertTrue(IndexSet(integer: 1) == is1.symmetricDifference(is2))
+        }
+        
+        do {
+            is1 = IndexSet(integersIn: 0..<5)
+            is2 = IndexSet(integersIn: 4..<10)
+            
+            expected = IndexSet(integer: 4)
+            
+            XCTAssertTrue(expected == is1.intersection(is2))
+            XCTAssertTrue(expected == is2.intersection(is1))
+        }
+        
+        do {
+            is1 = IndexSet([0, 2])
+            is2 = IndexSet([0, 1, 2])
+            XCTAssertTrue(is1 == is1.intersection(is2))
+        }
+        
+    }
+    
 }
diff --git a/TestFoundation/TestNSKeyedArchiver.swift b/TestFoundation/TestNSKeyedArchiver.swift
index 9bc233b..56f0067 100644
--- a/TestFoundation/TestNSKeyedArchiver.swift
+++ b/TestFoundation/TestNSKeyedArchiver.swift
@@ -159,7 +159,7 @@
     }
 
     func test_archive_locale() {
-        let locale = Locale.currentLocale()
+        let locale = Locale.current
         test_archive(locale)
     }
     
@@ -237,7 +237,7 @@
                 
                 // On Darwin decoded strings would belong to the autorelease pool, but as we don't have
                 // one in SwiftFoundation let's explicitly deallocate it here.
-                expectedCharPtr!.deallocateCapacity(charArray.count)
+                expectedCharPtr!.deallocate(capacity: charArray.count)
                 
                 return s1 == s2
         })
diff --git a/TestFoundation/TestNSRange.swift b/TestFoundation/TestNSRange.swift
index cdae25b..15a1bb8 100644
--- a/TestFoundation/TestNSRange.swift
+++ b/TestFoundation/TestNSRange.swift
@@ -66,4 +66,4 @@
         let swiftRange2 = range.toRange()
         XCTAssertEqual(swiftRange, swiftRange2)
     }
-}
\ No newline at end of file
+}
diff --git a/TestFoundation/TestNSStream.swift b/TestFoundation/TestNSStream.swift
new file mode 100644
index 0000000..790c65b
--- /dev/null
+++ b/TestFoundation/TestNSStream.swift
@@ -0,0 +1,242 @@
+// 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 TestNSStream : XCTestCase {
+    static var allTests: [(String, (TestNSStream) -> () throws -> Void)] {
+        return [
+            ("test_InputStreamWithData", test_InputStreamWithData),
+            ("test_InputStreamWithUrl", test_InputStreamWithUrl),
+            ("test_InputStreamWithFile", test_InputStreamWithFile),
+            ("test_InputStreamHasBytesAvailable", test_InputStreamHasBytesAvailable),
+            ("test_InputStreamInvalidPath", test_InputStreamInvalidPath),
+            ("test_outputStreamCreationToFile", test_outputStreamCreationToFile),
+            ("test_outputStreamCreationToBuffer", test_outputStreamCreationToBuffer),
+            ("test_outputStreamCreationWithUrl", test_outputStreamCreationWithUrl),
+            ("test_outputStreamCreationToMemory", test_outputStreamCreationToMemory),
+            ("test_outputStreamHasSpaceAvailable", test_outputStreamHasSpaceAvailable),
+            ("test_ouputStreamWithInvalidPath", test_ouputStreamWithInvalidPath),
+        ]
+    }
+    
+    func test_InputStreamWithData(){
+        let message: NSString = "Hello, playground"
+        let messageData: Data = message.data(using: String.Encoding.utf8.rawValue)!
+        let dataStream: InputStream = InputStream(data: messageData)
+        XCTAssertEqual(Stream.Status.notOpen, dataStream.streamStatus)
+        dataStream.open()
+        XCTAssertEqual(Stream.Status.open, dataStream.streamStatus)
+        var buffer = [UInt8](repeating: 0, count: 20)
+        if dataStream.hasBytesAvailable {
+            let result: Int = dataStream.read(&buffer, maxLength: buffer.count)
+            dataStream.close()
+            XCTAssertEqual(Stream.Status.closed, dataStream.streamStatus)
+            if(result > 0){
+                let output = NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue)
+                XCTAssertEqual(message, output!)
+            }
+        }
+    }
+    
+    func test_InputStreamWithUrl() {
+        let message: NSString = "Hello, playground"
+        let messageData: Data  = message.data(using: String.Encoding.utf8.rawValue)!
+        //Initialiser with url
+        let testFile = createTestFile("testFile_in.txt", _contents: messageData)
+        if testFile != nil {
+            let url = URL(fileURLWithPath: testFile!)
+            let urlStream: InputStream = InputStream(url: url)!
+            XCTAssertEqual(Stream.Status.notOpen, urlStream.streamStatus)
+            urlStream.open()
+            XCTAssertEqual(Stream.Status.open, urlStream.streamStatus)
+            var buffer = [UInt8](repeating: 0, count: 20)
+            if urlStream.hasBytesAvailable {
+                let result :Int = urlStream.read(&buffer, maxLength: buffer.count)
+                urlStream.close()
+                XCTAssertEqual(Stream.Status.closed, urlStream.streamStatus)
+                XCTAssertEqual(messageData.count, result)
+                if(result > 0) {
+                    let output = NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue)
+                    XCTAssertEqual(message, output!)
+                }
+            }
+            removeTestFile(testFile!)
+        } else {
+            XCTFail("Unable to create temp file")
+        }
+    }
+    
+    func test_InputStreamWithFile() {
+        let message: NSString = "Hello, playground"
+        let messageData: Data  = message.data(using: String.Encoding.utf8.rawValue)!
+        //Initialiser with file
+        let testFile = createTestFile("testFile_in.txt", _contents: messageData)
+        if testFile != nil {
+            let fileStream: InputStream = InputStream(fileAtPath: testFile!)!
+            XCTAssertEqual(Stream.Status.notOpen, fileStream.streamStatus)
+            fileStream.open()
+            XCTAssertEqual(Stream.Status.open, fileStream.streamStatus)
+            var buffer = [UInt8](repeating: 0, count: 20)
+            if fileStream.hasBytesAvailable {
+                let result: Int = fileStream.read(&buffer, maxLength: buffer.count)
+                fileStream.close()
+                XCTAssertEqual(Stream.Status.closed, fileStream.streamStatus)
+                XCTAssertEqual(messageData.count, result)
+                if(result > 0){
+                    let output = NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue)
+                    XCTAssertEqual(message, output!)
+                }
+            }
+            removeTestFile(testFile!)
+        } else {
+            XCTFail("Unable to create temp file")
+        }
+    }
+    
+    func test_InputStreamHasBytesAvailable() {
+        let message: NSString = "Hello, playground"
+        let messageData: Data  = message.data(using: String.Encoding.utf8.rawValue)!
+        let stream: InputStream = InputStream(data: messageData)
+        var buffer = [UInt8](repeating: 0, count: 20)
+        stream.open()
+        XCTAssertTrue(stream.hasBytesAvailable)
+        _ = stream.read(&buffer, maxLength: buffer.count)
+        XCTAssertFalse(stream.hasBytesAvailable)
+    }
+    
+    func test_InputStreamInvalidPath() {
+        let fileStream: InputStream = InputStream(fileAtPath: "/tmp/file.txt")!
+        XCTAssertEqual(Stream.Status.notOpen, fileStream.streamStatus)
+        fileStream.open()
+        XCTAssertEqual(Stream.Status.error, fileStream.streamStatus)
+    }
+    
+    func test_outputStreamCreationToFile() {
+        let filePath = createTestFile("TestFileOut.txt", _contents: Data(capacity: 256)!)
+        if filePath != nil {
+            let outputStream = NSOutputStream(toFileAtPath: filePath!, append: true)
+            XCTAssertEqual(Stream.Status.notOpen, outputStream!.streamStatus)
+            var myString = "Hello world!"
+            let encodedData = [UInt8](myString.utf8)
+            outputStream?.open()
+            XCTAssertEqual(Stream.Status.open, outputStream!.streamStatus)
+            let result: Int? = outputStream?.write(encodedData, maxLength: encodedData.count)
+            outputStream?.close()
+            XCTAssertEqual(myString.characters.count, result)
+            XCTAssertEqual(Stream.Status.closed, outputStream!.streamStatus)
+            removeTestFile(filePath!)
+        } else {
+            XCTFail("Unable to create temp file");
+        }
+    }
+    
+    func  test_outputStreamCreationToBuffer() {
+        var buffer = Array<UInt8>(repeating: 0, count: 12)
+        var myString = "Hello world!"
+        let encodedData = [UInt8](myString.utf8)
+        let outputStream = NSOutputStream(toBuffer: UnsafeMutablePointer<UInt8>(buffer), capacity: 12)
+        XCTAssertEqual(Stream.Status.notOpen, outputStream.streamStatus)
+        outputStream.open()
+        XCTAssertEqual(Stream.Status.open, outputStream.streamStatus)
+        let result: Int? = outputStream.write(encodedData, maxLength: encodedData.count)
+        outputStream.close()
+        XCTAssertEqual(Stream.Status.closed, outputStream.streamStatus)
+        XCTAssertEqual(myString.characters.count, result)
+        XCTAssertEqual(NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue),myString._bridgeToObject())
+    }
+    
+    func test_outputStreamCreationWithUrl() {
+        let filePath = createTestFile("TestFileOut.txt", _contents: Data(capacity: 256)!)
+        if filePath != nil {
+            let outputStream = NSOutputStream(url: URL(fileURLWithPath: filePath!), append: true)
+            XCTAssertEqual(Stream.Status.notOpen, outputStream!.streamStatus)
+            var myString = "Hello world!"
+            let encodedData = [UInt8](myString.utf8)
+            outputStream!.open()
+            XCTAssertEqual(Stream.Status.open, outputStream!.streamStatus)
+            let result: Int? = outputStream?.write(encodedData, maxLength: encodedData.count)
+            outputStream?.close()
+            XCTAssertEqual(myString.characters.count, result)
+            XCTAssertEqual(Stream.Status.closed, outputStream!.streamStatus)
+            removeTestFile(filePath!)
+        } else {
+            XCTFail("Unable to create temp file");
+        }
+    }
+    
+    func test_outputStreamCreationToMemory(){
+        var buffer = Array<UInt8>(repeating: 0, count: 12)
+        var myString = "Hello world!"
+        let encodedData = [UInt8](myString.utf8)
+        let outputStream = NSOutputStream.outputStreamToMemory()
+        XCTAssertEqual(Stream.Status.notOpen, outputStream.streamStatus)
+        outputStream.open()
+        XCTAssertEqual(Stream.Status.open, outputStream.streamStatus)
+        let result: Int? = outputStream.write(encodedData, maxLength: encodedData.count)
+        XCTAssertEqual(myString.characters.count, result)
+        //verify the data written
+        let dataWritten  = outputStream.propertyForKey(NSStreamDataWrittenToMemoryStreamKey)
+        if let nsdataWritten = dataWritten as? NSData {
+            nsdataWritten.getBytes(UnsafeMutablePointer<UInt8>(buffer), length: result!)
+            XCTAssertEqual(NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue), myString._bridgeToObject())
+            outputStream.close()
+        } else {
+            XCTFail("Unable to get data from memeory.")
+        }
+    }
+
+    func test_outputStreamHasSpaceAvailable() {
+        let buffer = Array<UInt8>(repeating: 0, count: 12)
+        var myString = "Welcome To Hello world  !"
+        let encodedData = [UInt8](myString.utf8)
+        let outputStream = NSOutputStream(toBuffer: UnsafeMutablePointer<UInt8>(buffer), capacity: 12)
+        outputStream.open()
+        XCTAssertTrue(outputStream.hasSpaceAvailable)
+        _ = outputStream.write(encodedData, maxLength: encodedData.count)
+        XCTAssertFalse(outputStream.hasSpaceAvailable)
+    }
+    
+    func test_ouputStreamWithInvalidPath(){
+        let outputStream = NSOutputStream(toFileAtPath: "http:///home/sdsfsdfd", append: true)
+        XCTAssertEqual(Stream.Status.notOpen, outputStream!.streamStatus)
+        outputStream?.open()
+        XCTAssertEqual(Stream.Status.error, outputStream!.streamStatus)
+    }
+    
+    private func createTestFile(_ path: String, _contents: Data) -> String? {
+        let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
+        do {
+            try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
+            if FileManager.default().createFile(atPath: tempDir + "/" + path, contents: _contents,
+                                                attributes: nil) {
+                return tempDir + path
+            } else {
+                return nil
+            }
+        } catch _ {
+            return nil
+        }
+    }
+    
+    private func removeTestFile(_ location: String) {
+        do {
+            try FileManager.default().removeItem(atPath: location)
+        } catch _ {
+            
+        }
+    }
+}
+
diff --git a/TestFoundation/TestNSString.swift b/TestFoundation/TestNSString.swift
index a78252c..f880a4f 100644
--- a/TestFoundation/TestNSString.swift
+++ b/TestFoundation/TestNSString.swift
@@ -395,7 +395,7 @@
         let testString = "hello world"
         let string = NSString(string: testString)
         let cfString = unsafeBitCast(string, to: CFString.self)
-        
+
         // Get the bytes as UTF16
         let reservedLength = 50
         var buf : [UInt8] = []
@@ -404,7 +404,7 @@
         let _ = buf.withUnsafeMutableBufferPointer { p in
             CFStringGetBytes(cfString, CFRangeMake(0, CFStringGetLength(cfString)), CFStringEncoding(kCFStringEncodingUTF16), 0, false, p.baseAddress, reservedLength, &usedLen)
         }
-        
+
         // Make a new string out of it
         let newCFString = CFStringCreateWithBytes(nil, buf, usedLen, CFStringEncoding(kCFStringEncodingUTF16), false)
         let newString = unsafeBitCast(newCFString, to: NSString.self)
@@ -1063,7 +1063,7 @@
     ComparisonTest("\u{0341}", "\u{0954}"),
 ]
 
-enum Stack: ErrorProtocol {
+enum Stack: Swift.Error {
     case Stack([UInt])
 }
 
@@ -1092,10 +1092,10 @@
             Array(String($0).unicodeScalars)
     }
     let expectHasPrefix = lhsNFDGraphemeClusters.starts(
-        with: rhsNFDGraphemeClusters, isEquivalent: (==))
+        with: rhsNFDGraphemeClusters, by: (==))
     let expectHasSuffix =
         lhsNFDGraphemeClusters.lazy.reversed().starts(
-            with: rhsNFDGraphemeClusters.lazy.reversed(), isEquivalent: (==))
+            with: rhsNFDGraphemeClusters.lazy.reversed(), by: (==))
 
     func testFailure(_ lhs: Bool, _ rhs: Bool, _ stack: [UInt]) -> Int {
         guard lhs == rhs else {
diff --git a/TestFoundation/TestNSTask.swift b/TestFoundation/TestNSTask.swift
index 06c27a0..c109cb2 100644
--- a/TestFoundation/TestNSTask.swift
+++ b/TestFoundation/TestNSTask.swift
@@ -261,7 +261,7 @@
     
 }
 
-private enum Error: ErrorProtocol {
+private enum Error: Swift.Error {
     case TerminationStatus(Int32)
     case UnicodeDecodingError(Data)
     case InvalidEnvironmentVariable(String)
diff --git a/TestFoundation/TestNSThread.swift b/TestFoundation/TestNSThread.swift
index bf8a9fe..59b8513 100644
--- a/TestFoundation/TestNSThread.swift
+++ b/TestFoundation/TestNSThread.swift
@@ -26,8 +26,8 @@
     }
 
     func test_currentThread() {
-        let thread1 = Thread.current()
-        let thread2 = Thread.current()
+        let thread1 = Thread.current
+        let thread2 = Thread.current
         XCTAssertNotNil(thread1)
         XCTAssertNotNil(thread2)
         XCTAssertEqual(thread1, thread2)
diff --git a/TestFoundation/TestNSURL.swift b/TestFoundation/TestNSURL.swift
index 1f7f20e..9b6ba91 100644
--- a/TestFoundation/TestNSURL.swift
+++ b/TestFoundation/TestNSURL.swift
@@ -60,7 +60,8 @@
             // TODO: these tests fail on linux, more investigation is needed
             ("test_fileURLWithPath", test_fileURLWithPath),
             ("test_fileURLWithPath_isDirectory", test_fileURLWithPath_isDirectory),
-            ("test_URLByResolvingSymlinksInPath", test_URLByResolvingSymlinksInPath)
+            ("test_URLByResolvingSymlinksInPath", test_URLByResolvingSymlinksInPath),
+            ("test_copy", test_copy)
         ]
     }
     
@@ -149,9 +150,12 @@
             result["parameterString"] = url.parameterString ?? kNullString
             result["relativePath"] = url.relativePath ?? kNullString
             result["isFileURL"] = url.isFileURL ? "YES" : "NO"
-            // Not yet implemented
-            // result["standardizedURL"] = url.standardizedURL?.relativeString ?? kNullString
-            
+            do {
+                let url = try url.standardized()
+                result["standardizedURL"] = url.relativeString
+            } catch {
+                result["standardizedURL"] = kNullString
+            } 
             // Temporarily disabled because we're only checking string results
             // result["pathComponents"] = url.pathComponents ?? kNullString
             result["lastPathComponent"] = url.lastPathComponent ?? kNullString
@@ -222,14 +226,11 @@
             }
             if let url = url {
 
-                // TODO: NSURL.standardizedURL isn't implemented yet.
-                var modifiedExpectedNSResult = expectedNSResult as! [String: Any]
-                modifiedExpectedNSResult["standardizedURL"] = nil
                 if title == "NSURLWithString-parse-ambiguous-url-001" {
                     // TODO: Fix this test
                 } else {
                     let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
-                    let (isEqual, differences) = compareResults(url, expected: modifiedExpectedNSResult, got: results)
+                    let (isEqual, differences) = compareResults(url, expected: expectedNSResult as! [String: Any], got: results)
                     XCTAssertTrue(isEqual, "\(title): \(differences)")
                 }
             } else {
@@ -447,6 +448,16 @@
             XCTFail()
         }
     }
+
+    func test_copy() {
+        let url = NSURL(string: "https://www.swift.org")
+        let urlCopy = url!.copy() as! NSURL
+        XCTAssertTrue(url!.isEqual(urlCopy))
+
+        let queryItem = NSURLQueryItem(name: "id", value: "23")
+        let queryItemCopy = queryItem.copy() as! NSURLQueryItem
+        XCTAssertTrue(queryItem.isEqual(queryItemCopy))
+    }
 }
     
 class TestNSURLComponents : XCTestCase {
diff --git a/TestFoundation/TestNSURLResponse.swift b/TestFoundation/TestNSURLResponse.swift
index 64d14e1..953241b 100644
--- a/TestFoundation/TestNSURLResponse.swift
+++ b/TestFoundation/TestNSURLResponse.swift
@@ -28,6 +28,7 @@
             ("test_suggestedFilename", test_suggestedFilename),
             ("test_suggestedFilename_2", test_suggestedFilename_2),
             ("test_suggestedFilename_3", test_suggestedFilename_3),
+            ("test_copywithzone", test_copyWithZone),
         ]
     }
     
@@ -85,6 +86,11 @@
         let res = URLResponse(url: url, mimeType: "txt", expectedContentLength: 0, textEncodingName: nil)
         XCTAssertEqual(res.suggestedFilename, "Unknown")
     }
+    func test_copyWithZone() {
+        let url = URL(string: "a/test/path")!
+        let res = URLResponse(url: url, mimeType: "txt", expectedContentLength: 0, textEncodingName: nil)
+        XCTAssertTrue(res.isEqual(res.copy()))
+    }
 }
 
 
diff --git a/TestFoundation/TestUnitConverter.swift b/TestFoundation/TestUnitConverter.swift
new file mode 100644
index 0000000..86bf9e1
--- /dev/null
+++ b/TestFoundation/TestUnitConverter.swift
@@ -0,0 +1,271 @@
+// 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 TestUnitConverter: XCTestCase {
+    
+    static var allTests: [(String, (TestUnitConverter) -> () throws -> Void)] {
+        return [
+            ("test_baseUnit", test_linearity),
+            ("test_linearity", test_linearity),
+            ("test_bijectivity", test_bijectivity),
+        ]
+    }
+    
+    func test_baseUnit() {
+        XCTAssertEqual(UnitAcceleration.baseUnit().symbol,
+                       UnitAcceleration.metersPerSecondSquared.symbol)
+        XCTAssertEqual(UnitAngle.baseUnit().symbol,
+                       UnitAngle.degrees.symbol)
+        XCTAssertEqual(UnitArea.baseUnit().symbol,
+                       UnitArea.squareMeters.symbol)
+        XCTAssertEqual(UnitConcentrationMass.baseUnit().symbol,
+                       UnitConcentrationMass.gramsPerLiter.symbol)
+        XCTAssertEqual(UnitDispersion.baseUnit().symbol,
+                       UnitDispersion.partsPerMillion.symbol)
+        XCTAssertEqual(UnitDuration.baseUnit().symbol,
+                       UnitDuration.seconds.symbol)
+        XCTAssertEqual(UnitElectricCharge.baseUnit().symbol,
+                       UnitElectricCharge.coulombs.symbol)
+        XCTAssertEqual(UnitElectricCurrent.baseUnit().symbol,
+                       UnitElectricCurrent.amperes.symbol)
+        XCTAssertEqual(UnitElectricPotentialDifference.baseUnit().symbol,
+                       UnitElectricPotentialDifference.volts.symbol)
+        XCTAssertEqual(UnitElectricResistance.baseUnit().symbol,
+                       UnitElectricResistance.ohms.symbol)
+        XCTAssertEqual(UnitEnergy.baseUnit().symbol,
+                       UnitEnergy.joules.symbol)
+        XCTAssertEqual(UnitFrequency.baseUnit().symbol,
+                       UnitFrequency.hertz.symbol)
+        XCTAssertEqual(UnitFuelEfficiency.baseUnit().symbol,
+                       UnitFuelEfficiency.litersPer100Kilometers.symbol)
+        XCTAssertEqual(UnitLength.baseUnit().symbol,
+                       UnitLength.meters.symbol)
+        XCTAssertEqual(UnitIlluminance.baseUnit().symbol,
+                       UnitIlluminance.lux.symbol)
+        XCTAssertEqual(UnitMass.baseUnit().symbol,
+                       UnitMass.kilograms.symbol)
+        XCTAssertEqual(UnitPower.baseUnit().symbol,
+                       UnitPower.watts.symbol)
+        XCTAssertEqual(UnitPressure.baseUnit().symbol,
+                       UnitPressure.newtonsPerMetersSquared.symbol)
+        XCTAssertEqual(UnitSpeed.baseUnit().symbol,
+                       UnitSpeed.metersPerSecond.symbol)
+        XCTAssertEqual(UnitTemperature.baseUnit().symbol,
+                       UnitTemperature.kelvin.symbol)
+        XCTAssertEqual(UnitVolume.baseUnit().symbol,
+                       UnitVolume.liters.symbol)
+    }
+    
+    func test_linearity() {
+        let coefficient = 7.0
+        let baseUnitConverter = UnitConverterLinear(coefficient: coefficient)
+        XCTAssertEqual(baseUnitConverter.value(fromBaseUnitValue: coefficient), 1.0)
+        XCTAssertEqual(baseUnitConverter.baseUnitValue(fromValue: 1), coefficient)
+    }
+    
+    func test_bijectivity() {
+        let delta = 1e-9
+        let testIdentity: (Dimension) -> Double = { dimension in
+            let converter = dimension.converter
+            return converter.value(fromBaseUnitValue: converter.baseUnitValue(fromValue: 1))
+        }
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAcceleration.metersPerSecondSquared), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAcceleration.gravity), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.degrees), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.arcMinutes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.arcSeconds), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.radians), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.gradians), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitAngle.revolutions), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareMegameters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareKilometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareMeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareCentimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareMillimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareMicrometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareNanometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareInches), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareFeet), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareYards), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.squareMiles), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.acres), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.ares), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitArea.hectares), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitConcentrationMass.gramsPerLiter), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitConcentrationMass.milligramsPerDeciliter), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(
+            testIdentity(UnitConcentrationMass.millimolesPerLiter(withGramsPerMole: 1)), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitDispersion.partsPerMillion), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitDuration.seconds), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitDuration.minutes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitDuration.hours), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.coulombs), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.megaampereHours), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.kiloampereHours), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.ampereHours), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.milliampereHours), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCharge.microampereHours), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCurrent.megaamperes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCurrent.kiloamperes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCurrent.amperes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCurrent.milliamperes), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricCurrent.microamperes), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricPotentialDifference.megavolts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricPotentialDifference.kilovolts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricPotentialDifference.volts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricPotentialDifference.millivolts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricPotentialDifference.microvolts), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricResistance.megaohms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricResistance.kiloohms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricResistance.ohms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricResistance.milliohms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitElectricResistance.microohms), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitEnergy.kilojoules), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitEnergy.joules), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitEnergy.kilocalories), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitEnergy.calories), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitEnergy.kilowattHours), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.terahertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.gigahertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.megahertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.kilohertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.hertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.millihertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.microhertz), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFrequency.nanohertz), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFuelEfficiency.litersPer100Kilometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFuelEfficiency.milesPerImperialGallon), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitFuelEfficiency.milesPerGallon), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.megameters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.kilometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.hectometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.decameters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.meters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.decimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.centimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.millimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.micrometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.nanometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.picometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.inches), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.feet), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.yards), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.miles), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.scandinavianMiles), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.nauticalMiles), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.fathoms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.furlongs), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.astronomicalUnits), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitLength.parsecs), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitIlluminance.lux), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.kilograms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.grams), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.decigrams), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.milligrams), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.nanograms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.picograms), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.ounces), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.pounds), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.stones), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.metricTons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.carats), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.ouncesTroy), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitMass.slugs), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.terawatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.gigawatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.megawatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.kilowatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.watts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.milliwatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.microwatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.nanowatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.picowatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.femtowatts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPower.horsepower), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.newtonsPerMetersSquared), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.gigapascals), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.megapascals), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.kilopascals), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.hectopascals), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.inchesOfMercury), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.bars), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.millibars), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.millimetersOfMercury), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitPressure.poundsForcePerSquareInch), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitSpeed.metersPerSecond), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitSpeed.kilometersPerHour), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitSpeed.milesPerHour), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitSpeed.knots), 1, accuracy: delta)
+        
+        XCTAssertEqualWithAccuracy(testIdentity(UnitTemperature.kelvin), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitTemperature.celsius), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitTemperature.fahrenheit), 1, accuracy: delta)
+
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.megaliters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.kiloliters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.liters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.deciliters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.milliliters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicKilometers), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicMeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicDecimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicCentimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicMillimeters), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicInches), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicFeet), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicYards), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cubicMiles), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.acreFeet), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.bushels), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.teaspoons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.tablespoons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.fluidOunces), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.cups), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.pints), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.quarts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.gallons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialTeaspoons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialTablespoons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialFluidOunces), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialPints), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialQuarts), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.imperialGallons), 1, accuracy: delta)
+        XCTAssertEqualWithAccuracy(testIdentity(UnitVolume.metricCups), 1, accuracy: delta)
+    }
+    
+}
diff --git a/TestFoundation/main.swift b/TestFoundation/main.swift
index ca2d8b2..40d5227 100644
--- a/TestFoundation/main.swift
+++ b/TestFoundation/main.swift
@@ -57,6 +57,7 @@
     testCase(TestNSRunLoop.allTests),
     testCase(TestNSScanner.allTests),
     testCase(TestNSSet.allTests),
+    testCase(TestNSStream.allTests),
     testCase(TestNSString.allTests),
 //    testCase(TestNSThread.allTests),
     testCase(TestNSTask.allTests),
@@ -78,4 +79,5 @@
     testCase(TestNSAttributedString.allTests),
     testCase(TestNSMutableAttributedString.allTests),
     testCase(TestNSFileHandle.allTests),
+    testCase(TestUnitConverter.allTests),
 ])
diff --git a/Tools/plutil/main.swift b/Tools/plutil/main.swift
index ec5cd15..7cd2067 100644
--- a/Tools/plutil/main.swift
+++ b/Tools/plutil/main.swift
@@ -59,7 +59,7 @@
     var inputs = [String]()
 }
 
-enum OptionParseError : ErrorProtocol {
+enum OptionParseError : Swift.Error {
     case UnrecognizedArgument(String)
     case MissingArgument(String)
     case InvalidFormat(String)
diff --git a/build.py b/build.py
index b1898cf..846cd3f 100644
--- a/build.py
+++ b/build.py
@@ -77,7 +77,7 @@
 	swift_cflags += ([
 		'-DDEPLOYMENT_ENABLE_LIBDISPATCH',
 		'-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
-		'-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src',
+		'-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src/swift',
 		'-Xcc -fblocks'
 	])
 	foundation.LDFLAGS += '-ldispatch -L'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/src/.libs -rpath \$$ORIGIN '
@@ -434,11 +434,13 @@
 
 script.add_product(foundation)
 
-LIBS_DIRS = "LD_LIBRARY_PATH=${BUILD_DIR}/Foundation/"
+LIBS_DIRS = ""
 if "XCTEST_BUILD_DIR" in Configuration.current.variables:
-    LIBS_DIRS += ":${XCTEST_BUILD_DIR}" 
+    LIBS_DIRS += "${XCTEST_BUILD_DIR}:"
 if "LIBDISPATCH_BUILD_DIR" in Configuration.current.variables:
-    LIBS_DIRS += ":"+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+"/src/.libs"
+    LIBS_DIRS += Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+"/src/.libs:"
+
+Configuration.current.variables["LIBS_DIRS"] = LIBS_DIRS
 
 extra_script = """
 rule InstallFoundation
@@ -457,7 +459,7 @@
 """
 extra_script += """
 rule RunTestFoundation
-    command = echo "**** RUNNING TESTS ****\\nexecute:\\nLD_LIBRARY_PATH=${LIBS_DIRS} ${BUILD_DIR}/TestFoundation/TestFoundation\\n**** DEBUGGING TESTS ****\\nexecute:\\nLD_LIBRARY_PATH=${LIBS_DIRS} lldb ${BUILD_DIR}/TestFoundation/TestFoundation\\n"
+    command = echo "**** RUNNING TESTS ****\\nexecute:\\nLD_LIBRARY_PATH=${BUILD_DIR}/Foundation/:${LIBS_DIRS} ${BUILD_DIR}/TestFoundation/TestFoundation\\n**** DEBUGGING TESTS ****\\nexecute:\\nLD_LIBRARY_PATH=${LIBS_DIRS} lldb ${BUILD_DIR}/TestFoundation/TestFoundation\\n"
     description = Building Tests
 
 build ${BUILD_DIR}/.test: RunTestFoundation | TestFoundation
diff --git a/configure b/configure
index 7cea036..32a3f2f 100755
--- a/configure
+++ b/configure
@@ -135,13 +135,13 @@
     config.config_path            = config.source_root.path_by_appending(".configuration")
 
     parser = argparse.ArgumentParser(description='Configure and emit ninja build scripts for building.')
-    parser.add_argument('--target', dest='target', type=str, default=Target.default())
-    parser.add_argument('--sysroot', dest='sysroot', type=str, default=None)
-    parser.add_argument('--toolchain', dest='toolchain', type=str, default=None)
-    parser.add_argument('--linker', dest='linker', type=str, default=None)
+    parser.add_argument('--target', dest='target', type=str, default=Target.default(), help="specify the deployment target")
+    parser.add_argument('--sysroot', dest='sysroot', type=str, default=None, help="the system root directory for building")
+    parser.add_argument('--toolchain', dest='toolchain', type=str, default=None, help="the base location for finding tools to compile")
+    parser.add_argument('--linker', dest='linker', type=str, default=None, help="which linker program to use")
     parser.add_argument('--pkg-config', dest='pkg_config', type=str, default="pkg-config")
-    parser.add_argument('--bootstrap', dest='bootstrap', type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "bootstrap"))
-    parser.add_argument('--reconfigure', dest='reconfigure', action="store_true")
+    parser.add_argument('--bootstrap', dest='bootstrap', type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "bootstrap"), help="a directory for bootstrapping commonly used headers and libraries not associated directly with the target operating system")
+    parser.add_argument('--reconfigure', dest='reconfigure', action="store_true", help="re-generate the build script given the previous configuration")
     parser.add_argument('-v', '--verbose', dest='verbose', action="store_true")
     args, extras = parser.parse_known_args()