     if let factor = parse(url.host, with: factorParser, defaultTo: nil) {
         if let secret = parse(queryDictionary[kQuerySecretKey], with: { MF_Base32Codec.dataFromBase32String($0) }, overrideWith: externalSecret) {
             if let algorithm = parse(queryDictionary[kQueryAlgorithmKey], with: algorithmFromString, defaultTo: Generator.defaultAlgorithm) {
-                if let digits = parse(queryDictionary[kQueryDigitsKey], with: { $0.toInt() }, defaultTo: Generator.defaultDigits) {
+                if let digits = parse(queryDictionary[kQueryDigitsKey], with: { Int($0) }, defaultTo: Generator.defaultDigits) {
                     if let core = Generator(factor: factor, secret: secret, algorithm: algorithm, digits: digits) {
 
                         var name = Token.defaultName
                         if let path = url.path {
-                            if count(path) > 1 {
+                            if path.characters.count > 1 {
                                 name = path.substringFromIndex(path.startIndex.successor()) // Skip the leading "/"
                             }
                         }

                        }
                        // If the name is prefixed by the issuer string, trim the name
                        if let prefixRange = name.rangeOfString(issuer) {
                            if (prefixRange.startIndex == issuer.startIndex) && (count(issuer) < count(name)) && (name[prefixRange.endIndex] == ":") {
                                name = name.substringFromIndex(prefixRange.endIndex.successor()).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
                            }
                        }

    if (url.scheme != kOTPAuthScheme) { return nil }

    var queryDictionary = Dictionary<String, String>()
    if let queryItems = NSURLComponents(URL: url, resolvingAgainstBaseURL: false)?.queryItems {
        for item in queryItems {
            queryDictionary[item.name] = item.value
        }
