     }
     
     func removePage(viewController: UIViewController) {
-        for var i = 0; i < self.viewControllers?.count; i += 1 {
+        for i in (0..<self.viewControllers!.count) {
             if (self.viewControllers?[i] == viewController) {
                 self.viewControllers?.removeAtIndex(i)
                 self.layoutPages()

    }
    
    override func viewDidLayoutSubviews() {
        for var i = 0; i < self.viewControllers?.count; i += 1 {
            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)
        }

    
    // 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)) {
