     }
     
     override func viewDidLayoutSubviews() {
-        for var i = 0; i < self.viewControllers?.count; i += 1 {
+        for i in (0..<self.viewControllers!.count) {
             let pageX:CGFloat = CGFloat(i) * self.view.bounds.size.width
             self.viewControllers?[i].view.frame = CGRectMake(pageX, 0.0, self.view.bounds.size.width, self.view.bounds.size.height)
         }

        for pageView in containerScrollView.subviews {
            pageView.removeFromSuperview()
        }
        
        for var i = 0; i < self.viewControllers?.count; i++ {
            let page = self.viewControllers?[i]
            self.addChildViewController(page!)
            let nextFrame:CGRect = CGRectMake(CGFloat(i) * self.view.bounds.size.width, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)

    
    // MARK: UIScrollViewDelegate
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        // Update the page when more than 50% of the previous/next page is visible
        let page = floor((containerScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1
        if (self.currentPage != Int(page)) {
