         } else {
             return
         }
-        
+
         moveToMenuPage(newPage, animated: true)
     }
-    
+
     // MARK: - Constructor
-    
+
     private func constructMenuView() {
+        menuView?.removeFromSuperview()
         menuView = MenuView(menuItemTitles: menuItemTitles, options: options)
         menuView.translatesAutoresizingMaskIntoConstraints = false
         view.addSubview(menuView)
-        
+
         addTapGestureHandlers()
         addSwipeGestureHandlersIfNeeded()
     }
-    
+
     private func layoutMenuView() {
-        let viewsDictionary = ["menuView": menuView]
-        let metrics = ["height": options.menuHeight]
-        let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[menuView]|", options: [], metrics: nil, views: viewsDictionary)
-        let verticalConstraints: [NSLayoutConstraint]
-        switch options.menuPosition {
-        case .Top:
-            verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[menuView(height)]", options: [], metrics: metrics, views: viewsDictionary)
-        case .Bottom:
-            verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:[menuView(height)]|", options: [], metrics: metrics, views: viewsDictionary)
-        }
-        
-        NSLayoutConstraint.activateConstraints(horizontalConstraints + verticalConstraints)
-        
-        menuView.setNeedsLayout()
-        menuView.layoutIfNeeded()
-    }
-    
+        NSLayoutConstraint(item: menuView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: options.menuHeight).active = true
+
+        for edge in [NSLayoutAttribute.Leading, .Trailing, options.menuPosition.layoutAttribute] {
+            NSLayoutConstraint(item: menuView, attribute: edge, relatedBy: .Equal, toItem: menuView.superview, attribute: edge, multiplier: 1, constant: 0).active = true
+        }
+    }
+
     private func constructContentScrollView() {
+        contentScrollView?.removeFromSuperview()
         contentScrollView = UIScrollView(frame: CGRectZero)
         contentScrollView.delegate = self
         contentScrollView.pagingEnabled = true
         contentScrollView.showsHorizontalScrollIndicator = false
         contentScrollView.showsVerticalScrollIndicator = false
         contentScrollView.scrollsToTop = false
-        contentScrollView.bounces = false
+        contentScrollView.bounces = true
         contentScrollView.scrollEnabled = options.scrollEnabled
         contentScrollView.translatesAutoresizingMaskIntoConstraints = false
         view.addSubview(contentScrollView)
     }
-    
+
     private func layoutContentScrollView() {
-        let viewsDictionary = ["contentScrollView": contentScrollView, "menuView": menuView]
-        let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[contentScrollView]|", options: [], metrics: nil, views: viewsDictionary)
-        let verticalConstraints: [NSLayoutConstraint]
-        switch options.menuPosition {
-        case .Top:
-            verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:[menuView][contentScrollView]|", options: [], metrics: nil, views: viewsDictionary)
-        case .Bottom:
-            verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[contentScrollView][menuView]", options: [], metrics: nil, views: viewsDictionary)
-        }
-        
-        NSLayoutConstraint.activateConstraints(horizontalConstraints + verticalConstraints)
-    }
-    
-    private func constructContentView() {
-        contentView = UIView(frame: CGRectZero)
-        contentView.translatesAutoresizingMaskIntoConstraints = false
-        contentScrollView.addSubview(contentView)
-    }
-    
-    private func layoutContentView() {
-        let viewsDictionary = ["contentView": contentView, "contentScrollView": contentScrollView]
-        let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[contentView]|", options: [], metrics: nil, views: viewsDictionary)
-        let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[contentView(==contentScrollView)]|", options: [], metrics: nil, views: viewsDictionary)
-        
-        NSLayoutConstraint.activateConstraints(horizontalConstraints + verticalConstraints)
-    }
-    
-    private func constructPagingViewControllers() {
-        for (index, pagingViewController) in pagingViewControllers.enumerate() {
-            // construct three child view controllers at a maximum, previous(optional), current and next(optional)
-            if !shouldLoadPage(index) {
-                // remove unnecessary child view controllers
-                if isVisiblePagingViewController(pagingViewController) {
-                    pagingViewController.willMoveToParentViewController(nil)
-                    pagingViewController.view!.removeFromSuperview()
-                    pagingViewController.removeFromParentViewController()
-                    
-                    if let viewIndex = visiblePagingViewControllers.indexOf(pagingViewController) {
-                        visiblePagingViewControllers.removeAtIndex(viewIndex)
-                    }
-                }
-                continue
-            }
-            
-            // ignore if it's already added
-            if isVisiblePagingViewController(pagingViewController) {
-                continue
-            }
-            
-            pagingViewController.view!.frame = CGRectZero
-            pagingViewController.view!.translatesAutoresizingMaskIntoConstraints = false
-
-            contentView.addSubview(pagingViewController.view!)
-            addChildViewController(pagingViewController as UIViewController)
-            pagingViewController.didMoveToParentViewController(self)
-            
-            visiblePagingViewControllers.append(pagingViewController)
-        }
-    }
-    
-    private func layoutPagingViewControllers() {
-        // cleanup
-        NSLayoutConstraint.deactivateConstraints(contentView.constraints)
-
-        var viewsDictionary: [String: AnyObject] = ["contentScrollView": contentScrollView]
-        for (index, pagingViewController) in pagingViewControllers.enumerate() {
-            if !shouldLoadPage(index) {
-                continue
-            }
-            
-            viewsDictionary["pagingView"] = pagingViewController.view!
-            var horizontalVisualFormat = String()
-            
-            // only one view controller
-            if (options.menuItemCount == options.minumumSupportedViewCount) {
-                horizontalVisualFormat = "H:|[pagingView(==contentScrollView)]|"
-            } else {
-                if case .Infinite = options.menuDisplayMode {
-                    if index == currentPage {
-                        viewsDictionary["previousPagingView"] = pagingViewControllers[previousIndex].view
-                        viewsDictionary["nextPagingView"] = pagingViewControllers[nextIndex].view
-                        horizontalVisualFormat = "H:[previousPagingView][pagingView(==contentScrollView)][nextPagingView]"
-                    } else if index == previousIndex {
-                        horizontalVisualFormat = "H:|[pagingView(==contentScrollView)]"
-                    } else if index == nextIndex {
-                        horizontalVisualFormat = "H:[pagingView(==contentScrollView)]|"
-                    }
-                } else {
-                    if index == 0 || index == previousIndex {
-                        horizontalVisualFormat = "H:|[pagingView(==contentScrollView)]"
-                    } else {
-                        viewsDictionary["previousPagingView"] = pagingViewControllers[index - 1].view
-                        if index == pagingViewControllers.count - 1 || index == nextIndex {
-                            horizontalVisualFormat = "H:[previousPagingView][pagingView(==contentScrollView)]|"
-                        } else {
-                            horizontalVisualFormat = "H:[previousPagingView][pagingView(==contentScrollView)]"
-                        }
-                    }
-                }
-            }
-            
-            let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat(horizontalVisualFormat, options: [], metrics: nil, views: viewsDictionary)
-            let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[pagingView(==contentScrollView)]|", options: [], metrics: nil, views: viewsDictionary)
-            
-            NSLayoutConstraint.activateConstraints(horizontalConstraints + verticalConstraints)
-        }
-
-        view.setNeedsLayout()
-        view.layoutIfNeeded()
-    }
-    
-    // MARK: - Cleanup
-    
-    private func cleanup() {
-        if let menuView = self.menuView, let contentScrollView = self.contentScrollView {
-            menuView.removeFromSuperview()
-            contentScrollView.removeFromSuperview()
-        }
-        currentPage = options.defaultPage
-    }
-    
+        guard let contentScrollView = contentScrollView where contentScrollView.superview != nil,
+            let menuView = menuView else { return }
+
+        for edge in [NSLayoutAttribute.Leading, .Bottom, .Trailing] {
+            NSLayoutConstraint(item: contentScrollView, attribute: edge, relatedBy: .Equal, toItem: contentScrollView.superview, attribute: edge, multiplier: 1, constant: 0).active = true
+        }
+
+        NSLayoutConstraint(item: contentScrollView, attribute: .Top, relatedBy: .Equal, toItem: menuView, attribute: .Bottom, multiplier: 1, constant: 0).active = true
+    }
+
+
     // MARK: - Gesture handler
-    
+
     private func addTapGestureHandlers() {
         menuView.menuItemViews.forEach { $0.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "handleTapGesture:")) }
     }
-    
+
     private func addSwipeGestureHandlersIfNeeded() {
         switch options.menuDisplayMode {
         case .Standard(_, _, .PagingEnabled): break

            contentScrollView.contentOffset.x = currentViewController.view!.frame.minX
        }
    }
    
    override public func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
        
        menuView.updateMenuViewConstraints(size: size)
        
        coordinator.animateAlongsideTransition({ [unowned self] (_) -> Void in
            self.view.setNeedsLayout()
            self.view.layoutIfNeeded()
            
            // reset selected menu item view position
            switch self.options.menuDisplayMode {
            case .Standard, .Infinite:
                self.menuView.moveToMenu(page: self.currentPage, animated: true)
            default: break
            }
        }, completion: nil)
    }
    
    public func setup(viewControllers viewControllers: [UIViewController], options: PagingMenuOptions) {
        self.options = options
        pagingViewControllers = viewControllers
        visiblePagingViewControllers.reserveCapacity(visiblePagingViewNumber)
        
        // validate
        validateDefaultPage()
        validatePageNumbers()
        
        // cleanup
        cleanup()
        
        currentPage = options.defaultPage
        
        constructMenuView()
        constructContentScrollView()
        layoutMenuView()
        layoutContentScrollView()
        constructContentView()
        layoutContentView()
        constructPagingViewControllers()
        layoutPagingViewControllers()

        currentPosition = currentPagingViewPosition()
        currentViewController = pagingViewControllers[currentPage]
        moveToMenuPage(currentPage, animated: false)
    }
    
    public func rebuild(viewControllers: [UIViewController], options: PagingMenuOptions) {
        // cleanup properties to avoid memory leaks. This could also be placed inside the cleanup method, or in within didSet{} of the pagingViewController
        visiblePagingViewControllers.removeAll()
        currentViewController = nil
        
        for childViewController in childViewControllers {
            childViewController.view.removeFromSuperview()
            childViewController.removeFromParentViewController()
        }

        // perform setup
        
        setup(viewControllers: viewControllers, options: options)
        
        view.setNeedsLayout()
        view.layoutIfNeeded()
    }
    
    // MARK: - UISCrollViewDelegate
    
    public func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        guard scrollView.isEqual(contentScrollView) else { return }

        let position = currentPagingViewPosition()
        
        // set new page number according to current moving direction
        switch position {
        case .Left: currentPage = previousIndex
        case .Right: currentPage = nextIndex
        default: return
        }

        delegate?.willMoveToMenuPage?(currentPage)
        menuView.moveToMenu(page: currentPage, animated: true)
        currentViewController = pagingViewControllers[currentPage]
        contentScrollView.contentOffset.x = currentViewController.view!.frame.minX

        constructPagingViewControllers()
        layoutPagingViewControllers()
        view.setNeedsLayout()
        view.layoutIfNeeded()

        currentPosition = currentPagingViewPosition()
        delegate?.didMoveToMenuPage?(currentPage)
    }
    
    // MARK: - UIGestureRecognizer
    
    internal func handleTapGesture(recognizer: UITapGestureRecognizer) {
        let tappedMenuView = recognizer.view as! MenuItemView
        guard let tappedPage = menuView.menuItemViews.indexOf(tappedMenuView) where tappedPage != currentPage else { return }
        
        let page = targetPage(tappedPage: tappedPage)
        moveToMenuPage(page, animated: true)
    }
    
    internal func handleSwipeGesture(recognizer: UISwipeGestureRecognizer) {
        var newPage = currentPage
        if recognizer.direction == .Left {

        menuView.panGestureRecognizer.requireGestureRecognizerToFail(rightSwipeGesture)
        menuView.addGestureRecognizer(rightSwipeGesture)
    }

    // MARK: - Page controller

    private func moveToMenuPage(let page: Int, animated: Bool) {
        guard let pagingViewControllers = pagingViewControllers else { return }
        let fromViewController = pagingViewControllers[currentPage]
        toViewController = pagingViewControllers[page] // use toViewController ivar here to avoid false appearance invokations. see scrollViewDidScroll:

        fromViewController.beginAppearanceTransition(false, animated: animated)
        toViewController?.beginAppearanceTransition(true, animated: animated)

        menuView.moveToMenu(page: page, animated: animated)
        delegate?.willMoveToMenuPage?(page)

        var actualPage = page
        let jumpPage: InfiniteCopyType?

        if case .Infinite = self.options.menuDisplayMode {
            let lastPage = pagingViewControllers.count - 1

            if currentPage == 0 && page == lastPage {
                // jump to back by scrolling to beginning, and jumping in completion block
                setupImageViewCopy(copyType: .Front)
                jumpPage = .Back
                actualPage = 0
            } else if currentPage == lastPage && page == 0 {
                // jump to front by scrolling to end, and jumping in completion block
                setupImageViewCopy(copyType: .Back)
                jumpPage = .Front
                actualPage = lastPage + 2 // jump to front by scrolling to copy
            } else {
                jumpPage = nil
                actualPage++ // increase by one (there's a copy of last VC's view at page 0)
            }
        } else {
            jumpPage = nil
        }

        let duration = animated ? options.animationDuration : 0
        let offsetX = view.bounds.width * CGFloat(actualPage)

        UIView.animateWithDuration(duration, animations: {
            [unowned self] in
            self.contentScrollView.contentOffset.x = offsetX
            }) { [unowned self] _ in
                fromViewController.endAppearanceTransition()
                self.toViewController?.endAppearanceTransition()
                self.toViewController = nil
                if let jumpPage = jumpPage {
                    self.jumpToPage(jumpPage)
                }

                self.delegate?.didMoveToMenuPage?(page)
        }
    }

    private func shouldLoadPage(index: Int) -> Bool {
