     func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
         
         // Set the collection view to the correct layout
-        let layout = self.collectionView.collectionViewLayout as! UICollectionViewFlowLayout
-        layout.itemSize = CGSizeMake(self.collectionView.frame.size.width / CGFloat(NUMBER_OF_DAYS_IN_WEEK), (self.collectionView.frame.size.height - layout.headerReferenceSize.height) / CGFloat(MAXIMUM_NUMBER_OF_ROWS))
-     
-        self.collectionView.collectionViewLayout = layout
+        let layout = self.calendarView.collectionViewLayout as! UICollectionViewFlowLayout
+        layout.itemSize = CGSizeMake(self.calendarView.frame.size.width / CGFloat(NUMBER_OF_DAYS_IN_WEEK), (self.calendarView.frame.size.height - layout.headerReferenceSize.height) / CGFloat(MAXIMUM_NUMBER_OF_ROWS))
+     
+        self.calendarView.collectionViewLayout = layout
         
         
         if let dateSource = self.dataSource {

            elementFrame.origin.y += elementFrame.size.height
            elementFrame.size.height = self.frame.size.height - elementFrame.size.height
            
            self.collectionView.frame = CGRect(x:0.0, y:80.0, width: self.frame.size.width, height:self.frame.size.height - 80.0)
            
            let layout = self.collectionView.collectionViewLayout as! KDCalendarFlowLayout
            
            self.collectionView.collectionViewLayout = layout
            
        }
    }

        
    }()
    
    lazy var calendarView : UICollectionView = {
     
        let layout = KDCalendarFlowLayout()
        layout.scrollDirection = UICollectionViewScrollDirection.Horizontal
