     
     func pathsFromDates(dates:[NSDate])-> [NSIndexPath] {
         var returnPaths: [NSIndexPath] = []
-        
         for date in dates {
             if date >= startOfMonthCache && date <= endOfMonthCache {
                 let periodApart = calendar.components(.Month, fromDate: startOfMonthCache, toDate: date, options: [])

                if !self.scrollInProgress { // Make sure this scroll only gets activated if no other scroll is in queue
                    self.configureChangeOfRows()
                    
                    guard let validAnchorDate = anchorDate else { // If the date is invalid just scroll to the the first item on the view or scroll to the start of a header (if header is enabled)
                        if headerViewXibs.count < 1 {
                            self.scrollToDate(self.startOfMonthCache, triggerScrollToDateDelegate: false, animateScroll: animation, completionHandler: completionHandler)
                        } else {
                            self.scrollToHeaderForDate(self.startOfMonthCache, triggerScrollToDateDelegate: false, withAnimation: animation, completionHandler: completionHandler)
                        }
                        return
                    }
                    
                    delayRunOnMainThread(0.0, closure: { () -> () in
                        self.scrollToDate(validAnchorDate, triggerScrollToDateDelegate: false, animateScroll: animation, completionHandler: completionHandler)
                    })
                } else {
                    if let validHandler = completionHandler {
                        self.delayedExecutionClosure.append(validHandler)
                    }
                }
                
                // Set layoutNeedsUpdating to false

                returnPaths.append(NSIndexPath(forItem: adjustedCellIndex, inSection: adjustedSection))
            }
        }
        return returnPaths
    }
}
