 
 #if DEBUG
     
+    // Shim for dispatch_once and DISPATCH_CURRENT_QUEUE_LABEL in swift 3 from http://stackoverflow.com/a/38311178 and https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160613/002280.html
+    public extension DispatchQueue {
+        
+        private static var _onceTracker = [String]()
+        
+        /**
+         Executes a block of code, associated with a unique token, only once.  The code is thread safe and will
+         only execute the code once even in the presence of multithreaded calls.
+         
+         - parameter token: A unique reverse DNS style name such as com.vectorform.<name> or a GUID
+         - parameter block: Block to execute once
+         */
+        public class func once(token: String, block:@noescape(Void)->Void) {
+            objc_sync_enter(self); defer { objc_sync_exit(self) }
+            
+            if _onceTracker.contains(token) {
+                return
+            }
+            
+            _onceTracker.append(token)
+            block()
+        }
+        
+        class var currentLabel: String? {
+            return String(validatingUTF8: __dispatch_queue_get_label(nil))
+        }
+    }
+    
     extension UIView {
         public override class func initialize() {
-            struct Static {
-                static var token: dispatch_once_t = 0
-            }
             
             // make sure this isn't a subclass
             if self !== UIView.self {
                 return
             }
             
-            dispatch_once(&Static.token) {
+            DispatchQueue.once(token: "NBUIKitMainThreadGuardInitialize", block: { () in
                 let swizzle = { (cls: AnyClass, originalSelector: Selector, swizzledSelector: Selector) in
                     let originalMethod = class_getInstanceMethod(cls, originalSelector)
                     let swizzledMethod = class_getInstanceMethod(cls, swizzledSelector)

                for method in ["setNeedsLayout", "setNeedsDisplay", "setNeedsDisplayInRect"] {
                    swizzle(self, Selector(method), Selector("nb_\(method)"))
                }
            }
        }
        
        // MARK: - Method Swizzling

        
        func nb_setNeedsDisplayInRect(rect: CGRect) {
            self.nb_mainThreadCheck()
            self.nb_setNeedsDisplayInRect(rect: rect)
        }
    }
    
