             var frames: [String: CGRect]?
             if areCollisions {
                 // Register possible collisions as constraints
-                for (frame1, frameList) in possibleFrameCollisions {
+                for (frame1, frameList) in frameCollisions {
                     let index1 = frameIndices[frame1]!
                     for frame2 in frameList {
                         let index2 = frameIndices[frame2]!


    // Trigger the backtrack algorithm and check if solution is valid.
    func backtrack() -> [String: CGRect]? {
        if !backtrack(depth: 0) && !cancelled {
            print("BACKTRACK FAILED ON VARIABLES: \(variables)")
        }
        if cancelled {
            return nil
        }
        else {
            var solution: [String: CGRect] = [:]
            for vari in variables {
                solution[vari.id] = vari.cgRect
            }
            return solution
        }
    }

    // Backtracking algorithm/
    private func backtrack(depth: Int) -> Bool {

        let domain = domains[depth].sorted(by: { (v1, v2) -> Bool in
            if v1.width.isEqual(to: v2.width, decimalPlaces: 12) {

        })

        for value in domain {
            if Date.timeIntervalSinceReferenceDate-startTime > 0.95 {
                return .timeout
            }
            if cancelled {
                return .cancelled
            }

            let activeFrame = variables[depth]
            activeFrame.applyValue(value)
            var noFails = true
