     }
     
     func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return sections[section].cellRows.count ?? 0
+        return sections[safe: section]?.cellRows.count ?? 0
     }
     
     func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
-        let cellRow = sections[indexPath.section].cellRows[indexPath.row]
+        guard let cellRow = sections[safe: indexPath.section]?.cellRows[safe: indexPath.row] else { fatalError("wrong index path for cell") }
         let cell = tableView.dequeueReusableCellWithIdentifier(rowIdFromClass(cellRow.cellClass), forIndexPath: indexPath)
         cellRow.configureCell(cell)
         return cell

    func scrollViewDidScroll(scrollView: UIScrollView) {
        delegate?.scrollViewDidScroll?(scrollView)
    }
    
}

    // MARK: UITableViewDelegate
    
    func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        guard let header = sections[safe: section]?.header else { fatalError("wrong section number for header") }
        let view = tableView.dequeueReusableHeaderFooterViewWithIdentifier(rowIdFromClass(header.viewClass))!
        header.configureView(view)
        return view
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        let cellRow = sections[safe: indexPath.section]?.cellRows[indexPath.row]
        return cellRow?.cellHeight ?? 0
    }
    
    func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        guard let cellRow = sections[safe: indexPath.section]?.cellRows[indexPath.row] else { fatalError("wrong index path for cell") }
        return cellRow.cellEstimatedHeight
    }
    
    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        guard let header = sections[safe: section]?.header else { fatalError("wrong section number for header") }
        return header.viewHeight
    }
    
    func tableView(tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
        return sections[safe: section]?.header?.viewEstimatedHeight ?? 0
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let cellRow = sections[safe: indexPath.section]?.cellRows[indexPath.row]
        cellRow?.cellSelected?()
    }
    
    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        let cellRow = sections[safe: indexPath.section]?.cellRows[indexPath.row]
        cellRow?.willDisplayCell?()
    }
    
    // MARK:UIScrollViewDelegate
