     }
     
     func sizeOfSection(section: Int)-> CGFloat {
-        var size = CGSizeZero
         let headerSizeOfPreviousSection = headerCache[section].frame.height
-        
-        let itemSectionSizeOfPreviousSection = cellCache[section]![0].frame.height * CGFloat(numberOfRows)
         if scrollDirection == .Horizontal {
-                return cellCache[section]![0].frame.width * CGFloat(numberOfColumns)
+            return cellCache[section]![0].frame.width * CGFloat(numberOfColumns)
         } else {
             return cellCache[section]![0].frame.height * CGFloat(numberOfRows) + headerSizeOfPreviousSection
         }

        // Use the calculaed header size and force thw width of the header to take up 7 columns
        let modifiedSize = CGSize(width: itemSize.width * CGFloat(numberOfColumns), height: headerSize.height)
        
        
        
        attributes.frame = scrollDirection == .Horizontal ?
            CGRect(x: strideOffset, y: 0, width: modifiedSize.width, height: modifiedSize.height) :
            CGRect(x: 0, y: strideOffset, width: modifiedSize.width, height: modifiedSize.height)
        if attributes.frame == CGRectZero { return nil }
        
        return attributes
    }
    
    func applyLayoutAttributes(attributes : UICollectionViewLayoutAttributes) {
        if attributes.representedElementKind != nil { return }
        guard let collectionView = self.collectionView else { return }
    
        // Calculate the item size
        if let itemSize = delegate!.itemSize {

        for sectionIndex in startSectionIndex..<cellCache.count {
            if let validSection = cellCache[sectionIndex] where validSection.count > 0 {
                // Add header view attributes
                if headerViewXibs.count > 0 {
                    if CGRectIntersectsRect(headerCache[sectionIndex].frame, rect) { attributes.append(headerCache[sectionIndex]) }
                }
                
                for val in validSection {
