 					let oldBufferSize = newMaxBufferSize
 					
 					newMaxBufferSize += min(newMaxBufferSize, 4*1024 /* 4KB */)
-					newBuffer = UnsafeMutablePointer<UInt8>(allocatingCapacity: newMaxBufferSize)
+					newBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: newMaxBufferSize)
 //					if newBuffer == nil {throw BSONSerializationError.cannotAllocateMemory(newMaxBufferSize)}
-					newBuffer.assignFrom(oldBuffer, count: newBufferValidLength)
+					newBuffer.assign(from: oldBuffer, count: newBufferValidLength)
 					newBufferStart = newBuffer; newBufferEnd = newBufferStart.advanced(by: newBufferValidLength)
 					
-					if oldBuffer != buffer {oldBuffer.deallocateCapacity(oldBufferSize)}
+					if oldBuffer != buffer {oldBuffer.deallocate(capacity: oldBufferSize)}
 				}
 			}
 			

			let biggerBuffer = unsafeBitCast(m, to: UnsafeMutablePointer<UInt8>.self)
			
			/* Copying data in our given buffer to the new buffer. */
			biggerBuffer.assignFrom(bufferStart, count: bufferValidLength) /* size is greater than maxBufferSize. We know we will never overflow our own buffer using bufferValidLength */
			var newStartPos = 0, newValidLength = bufferValidLength
			
			bufferStartPos = 0; bufferValidLength = 0

class BSONSerialization {
	
	/** The BSON Serialization errors enum. */
	enum BSONSerializationError : Error {
		/** The given data/stream contains too few bytes to be a valid bson doc. */
		case dataTooSmall
		/** The given data size is not the one declared by the bson doc. */
