         
          // Generate and cache the headers
         for section in 0..<maxSections {
-            
             if headerViewXibs.count > 0 {
                 // generate header views
                 let sectionIndexPath = NSIndexPath(forItem: 0, inSection: section)
                 if let aHeaderAttr = layoutAttributesForSupplementaryViewOfKind(UICollectionElementKindSectionHeader, atIndexPath: sectionIndexPath) {
                     headerCache.append(aHeaderAttr)
-                    
-                    if scrollDirection == .Vertical {
-                        contentHeight += aHeaderAttr.frame.height
-                    }
+                    if scrollDirection == .Vertical { contentHeight += aHeaderAttr.frame.height } else { contentWidth += aHeaderAttr.frame.width }
                 }
             }
             

            let headerOrigin = headerCache[attributes.indexPath.section].frame.origin.y
            stride += headerSize + headerOrigin
        } else { // If there are no headers then alll the cells will have the same height, therefore the strides will have the same height
            let sectionHeight = itemSize.height * CGFloat(numberOfRows)
            stride = CGFloat(attributes.indexPath.section) * sectionHeight
        }
        
        var xCellOffset : CGFloat = CGFloat(attributes.indexPath.item % 7) * self.itemSize.width

                        
                        if scrollDirection == .Vertical {
                            contentHeight += (attribute.frame.height * CGFloat(numberOfRows))
                        } else {
                            contentWidth += (attribute.frame.width * CGFloat(numberOfColumns))
                        }
                    }
                    cellCache[section]!.append(attribute)
                }
            }

        }
        
        if scrollDirection == .Horizontal {
//            contentWidth = self.collectionView!.bounds.size.width * CGFloat(numberOfMonthsInCalendar * numberOfSectionsPerMonth)
            contentHeight = self.collectionView!.bounds.size.height
        } else {
            contentWidth = self.collectionView!.bounds.size.width
