 class S2Helper {
     static let sharedInstance = S2Helper()
     
-    var lookupPos: [Int] = []
+    var lookupPos: [Int?] = []
     
     init() {
+        for _ in 0..<(1 << (2 * S2Constants.lookupBits + 2)) {
+            lookupPos.append(nil)
+        }
         initLookupCell(0, i: 0, j: 0, origOrientation: 0, pos: 0, orientation: 0)
         initLookupCell(0, i: 0, j: 0, origOrientation: S2Constants.swapMask, pos: 0, orientation: S2Constants.swapMask)
         initLookupCell(0, i: 0, j: 0, origOrientation: S2Constants.invertMask, pos: 0, orientation: S2Constants.invertMask)


enum S2Constants {
    static let maxLevel = 30
    static let posBits = 2 * (S2Constants.maxLevel + 1)
    static let maxSize = 1 << S2Constants.maxLevel
    static let swapMask = 0x01
    static let invertMask = 0x02

}

class S2CellId {
    var id: UInt64
    
    init(id: UInt64) {
        self.id = id
    }
    
