 	- Throws: `BSONSerializationError` in case of error.
 	- Returns: The serialized BSON data.
 	*/
-	class func BSONObject(stream: InputStream, options opt: BSONReadingOptions) throws -> [String: AnyObject] {
-		precondition(sizeof(Double.self) == 8, "I currently need Double to be 64 bits")
+	class func BSONObject(stream: InputStream, options opt: BSONReadingOptions) throws -> [String: Any] {
+		precondition(MemoryLayout<Double>.size == 8, "I currently need Double to be 64 bits")
 		
 		var bufferSize = 0
 		var posInBuffer = 0
 		var totalBytesRead = 0
 		let maxBufferSize = 1024*1024 /* 1MB */
-		let buffer = UnsafeMutablePointer<UInt8>(allocatingCapacity: maxBufferSize)
+		let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: maxBufferSize)
 //		if buffer == nil {throw BSONSerializationError.cannotAllocateMemory(maxBufferSize)}
-		defer {buffer.deallocateCapacity(maxBufferSize)}
+		defer {buffer.deallocate(capacity: maxBufferSize)}
 		
 		/* TODO: Handle endianness! */
 		

		return ret
	}
	
	class func data(BSONObject: AnyObject, options opt: BSONWritingOptions) throws -> Data {
		return Data()
	}
	
	class func write(BSONObject: AnyObject, toStream stream: NSOutputStream, options opt: BSONWritingOptions, error: NSErrorPointer) -> Int {
		return 0
	}
	
	class func isValidBSONObject(_ obj: AnyObject) -> Bool {
		return false
	}
	

	- Returns: The required type.
	*/
	private class func readType<Type>(buffer: UnsafeMutablePointer<UInt8>, bufferStartPos: inout Int, bufferValidLength: inout Int, maxBufferSize: Int, totalNReadBytes: inout Int, stream: InputStream) throws -> Type {
		let data = try readDataFromBuffer(dataSize: MemoryLayout<Type>.size, alwaysCopyBytes: false, buffer: buffer, bufferStartPos: &bufferStartPos, bufferValidLength: &bufferValidLength, maxBufferSize: maxBufferSize, totalNReadBytes: &totalNReadBytes, stream: stream)
		assert(data.count == MemoryLayout<Type>.size)
		return unsafeBitCast((data as NSData).bytes, to: UnsafePointer<Type>.self).pointee
	}
	
