         self.view.addConstraint(NSLayoutConstraint(item:popover, attribute:.right, relatedBy:.equal, toItem:self.settingsButton, attribute:.left, multiplier:1.0, constant:-6.0))
         self.view.addConstraint(NSLayoutConstraint(item:popover, attribute:.bottom, relatedBy:.equal, toItem:self.settingsButton, attribute:.top, multiplier:1.0, constant:-6.0))
         
+        popover.reloadColors()
         
-        popover.reloadColors()
-    }
+        return popover
+    }()
+    
     
     func isSettingsPopoverVisible() -> Bool {
         
-        guard let popover = self.settingsPopover else {
-            fatalError()
-        }
+        let popover = self.settingsPopover
         
         if popover.alpha > 0 {
             return true

    
    func toggleSettingsPopover() {
        
        guard let popover = self.settingsPopover else {
            fatalError()
        }
        
        UIView.animate(withDuration: 0.10) {
            if popover.alpha > 0 {


import UIKit

class ViewController: UIViewController {
    
    static let numColors = 16
    static let numColumns = 4
    
    @IBOutlet var settingsButton: UIButton?
    let saturation = 60 // 0-100
    let brightness = 85 // 0-100
    
    lazy var settingsPopover : SettingsPopover = {
        
        if !self.isViewLoaded {
            fatalError()
