     }
     
     override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        switch section {
-        case 0 where beforeTimeSlot != nil :
-            return 1
-        case 5 where endTimeSlot != nil :
-            return 1
-        case 1 where socialDaySlots != nil :
-            return socialDaySlots.count
-        case 2 where firstDaySlots != nil :
-            return firstDaySlots.count
-        case 3 where secondDaySlots != nil :
-            return secondDaySlots.count
-        case 4 where hackathonSlots != nil :
-            return hackathonSlots.count
-        default : return 0
-        }
+        return events[section].count
     }
     
     override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let context = Context()
    var groupOfEvents : Group!
    
    let sectionNames = ["Before Conference", "Social Day", "First Day", "Second Day", "Hackathon", "The End"]
    
    var beforeTimeSlot : Entity!
    var endTimeSlot : Entity!
    var socialDaySlots : [Entity]!
    var firstDaySlots : [Entity]!
    var secondDaySlots : [Entity]!
    var hackathonSlots : [Entity]!
    
    lazy var events : [[Entity]] = [[self.beforeTimeSlot], self.socialDaySlots, self.firstDaySlots, self.secondDaySlots, self.hackathonSlots, [self.endTimeSlot]]

    lazy var reload : dispatch_block_t = dispatch_debounce_block(0.1) {
        let events = sorted(self.groupOfEvents) {

            return e1.get(StartTimeComponent)!.date.timeIntervalSinceReferenceDate < e2.get(StartTimeComponent)!.date.timeIntervalSinceReferenceDate
        }
        
        for i in 0...5 {
            self.events[i] = []
        }
        
        let cal = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
        
        self.events[0].append(events.first!)
        self.events[5].append(events.last!)
        
        for event in events {
            if !event.has(StartTimeComponent) || !event.has(EndTimeComponent){
                continue
            }
            let day = cal.component(NSCalendarUnit.CalendarUnitDay, fromDate: event.get(StartTimeComponent)!.date)
            let index = day - 16
            self.events[index].append(event)
        }
        
        self.tableView.reloadData()
    }
