     
     
     func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
-        return self.sectionAtIndexPath(NSIndexPath(forRow: 0, inSection: section)).headerTitle
+        if let section = self.sectionAtIndexPath(NSIndexPath(forRow: 0, inSection: section)) {
+            return section.headerTitle
+        }
+        return nil
     }
     
     func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
-        return self.sectionAtIndexPath(NSIndexPath(forRow: 0, inSection: section)).footerTitle
+        if let section = self.sectionAtIndexPath(NSIndexPath(forRow: 0, inSection: section)) {
+            return section.footerTitle
+        }
+        return nil
     }
     
     func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
-        
-        if let dataSource = self.dataSource {
-            if indexPath.section < dataSource.sections.count {
-                let section = self.sectionAtIndexPath(indexPath)
-                if (indexPath.row < section.items.count) {
-                    let item = self.itemAtIndexPath(indexPath)
-                    return item.editingStyle != .None || item.moveHandler != nil
-                }
-            }
+        if let item = self.itemAtIndexPath(indexPath) {
+            return item.editingStyle != .None || item.moveHandler != nil
         }
         return false
     }
     
     func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
-        return self.itemAtIndexPath(indexPath).moveHandler != nil
+        if let item = self.itemAtIndexPath(indexPath) {
+            return item.moveHandler != nil
+        }
+        return false
     }
     
     func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]! {

    
    // MARK: Private methods
    //
    private func sectionAtIndexPath(indexPath: NSIndexPath) -> TableViewSection {
        return self.dataSource?.sections[indexPath.section] as TableViewSection!
    }
    
    private func itemAtIndexPath(indexPath: NSIndexPath) -> TableViewItem {
        let section = self.sectionAtIndexPath(indexPath)
        return section.items[indexPath.row] as TableViewItem!
    }
    
    // MARK: <UITableViewDataSource> methods

    */

    func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) -> NSIndexPath {
        if let sourceSection = self.sectionAtIndexPath(sourceIndexPath), let item = self.itemAtIndexPath(sourceIndexPath), let moveHandler = item.moveHandler {
            let allowed = moveHandler(section: sourceSection, item: item, tableView: tableView, sourceIndexPath: sourceIndexPath, destinationIndexPath: proposedDestinationIndexPath)
            if !allowed {
                return sourceIndexPath
            }
        }
        return proposedDestinationIndexPath
    }

    func tableView(tableView: UITableView, indentationLevelForRowAtIndexPath indexPath: NSIndexPath) -> Int {
        if let item = self.itemAtIndexPath(indexPath) {
            return item.indentationLevel
        }
        return 0
    }
    
    func tableView(tableView: UITableView, shouldShowMenuForRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        if let item = self.itemAtIndexPath(indexPath) {
            return item.copyHandler != nil || item.pasteHandler != nil || item.cutHandler != nil
        }
        return false
    }
    
    func tableView(tableView: UITableView, canPerformAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject) -> Bool {
        if let item = self.itemAtIndexPath(indexPath) {
            if item.copyHandler != nil && action == Selector("copy:") {
                return true
            }
            if item.pasteHandler != nil && action == Selector("paste:") {
                return true
            }
            if item.cutHandler != nil && action == Selector("cut:") {
                return true
            }
        }
        return false
    }
    
    func tableView(tableView: UITableView, performAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject!) {
        if let item = self.itemAtIndexPath(indexPath), let section = self.sectionAtIndexPath(indexPath) {
            if let copyHandler = item.copyHandler where action == Selector("copy:") {
                copyHandler(section: section, item: item, tableView: tableView, indexPath: indexPath)
            }
            if let pasteHandler = item.pasteHandler where action == Selector("paste:") {
                pasteHandler(section: section, item: item, tableView: tableView, indexPath: indexPath)
            }
            if let cutHandler = item.cutHandler where action == Selector("cut:") {
                cutHandler(section: section, item: item, tableView: tableView, indexPath: indexPath)
            }
        }
    }
}