     
     public required init?(coder: NSCoder) {
         super.init(coder: coder)
-    }
-    
-    public override func awakeFromNib() {
+        self.setup()
+    }
+    
+    override init(frame frameRect: NSRect) {
+        super.init(frame: frameRect)
+        self.setup()
+    }
+    
+    func setup() {
         self.wantsLayer = true
         self.translatesAutoresizingMaskIntoConstraints = false
         

        
    }
    
    // MARK: Editing
    
    // MARK: Drawing
    
    override public var opaque: Bool {
        return true

    // MARK: Data Source
    
    public func reloadTabs() {
        guard let dataSource = self.dataSource else {
            // no effect if there is dataSource
            return
        }
        
        let tabCell = self.cell as! TabButtonCell
        self.tabButtons().forEach { $0.removeFromSuperview() }
        
        let newItemsCount = dataSource.tabsControlNumberOfTabs(self)
        for i in 0..<newItemsCount {
            let item = dataSource.tabsControl(self, itemAtIndex: i)
            let button = TabButton(withItem: item, target: self, action: #selector(TabsControl.selectTab(_:)))
            
            var borderMask = tabCell.borderMask
            if i == 0 && self.automaticSideBorderMasks == true {
                borderMask = borderMask.union(.Left)
            }
            if i == newItemsCount-1 && self.automaticSideBorderMasks == true {
                borderMask = borderMask.union(.Right)
            }
            let buttonCell = button.cell as! TabButtonCell
            buttonCell.borderMask = borderMask
            
            button.title = dataSource.tabsControl(self, titleForItem: item)
//            button.state = (item == self.selectedItem) ? NSOnState : NSOffState
            button.highlight(self.isHighlighted)
            
            if let img = dataSource.tabsControl?(self, iconForItem: item) {
                button.icon = img
            }
            if let menu = dataSource.tabsControl?(self, menuForItem: item) {
                button.menu = menu
            }
            if let altIcon = dataSource.tabsControl?(self, titleAlternativeIconForItem: item) {
                button.alternativeTitleIcon = altIcon
            }
            
            self.tabsView?.addSubview(button)
        }
        
        self.layoutTabButtons(nil, animated: false)
        self.updateAuxiliaryButtons()
        self.invalidateRestorableState()
    }
    
    private func layoutTabButtons(buttons: Array<TabButton>?, animated anim: Bool) {
