     if (url.scheme != kOTPAuthScheme) { return nil }
 
     var queryDictionary = Dictionary<String, String>()
-    if let queryItems = NSURLComponents(URL:url, resolvingAgainstBaseURL:false).queryItems as? [NSURLQueryItem] {
+    if let queryItems = NSURLComponents(URL: url, resolvingAgainstBaseURL: false)?.queryItems as? [NSURLQueryItem] {
         for item in queryItems {
             queryDictionary[item.name] = item.value
         }

    public struct URLSerializer: TokenSerializer {
        public static func serialize(token: Token) -> String? {
            let url = urlForToken(name: token.name, issuer: token.issuer, factor: token.core.factor, algorithm: token.core.algorithm, digits: token.core.digits)
            return url.absoluteString
        }

        public static func deserialize(string: String, secret: NSData? = nil) -> Token? {
            if let url = NSURL.URLWithString(string) {
                return tokenFromURL(url, secret: secret)
            }
            return nil

    return nil
}

private func urlForToken(#name: String, #issuer: String, #factor: Generator.Factor, #algorithm: Generator.Algorithm, #digits: Int) -> NSURL? {
    let urlComponents = NSURLComponents()
    urlComponents.scheme = kOTPAuthScheme
    urlComponents.path = "/" + name

    var queryItems = [
        NSURLQueryItem(name:kQueryAlgorithmKey, value:stringForAlgorithm(algorithm)),
        NSURLQueryItem(name:kQueryDigitsKey, value:String(digits)),
        NSURLQueryItem(name:kQueryIssuerKey, value:issuer)
