     override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
         
         var cell : UITableViewCell!
-        let parent = self.findParent(indexPath.row)
-
-        if self.isChildCell(indexPath) {
+        
+        let (parent, isParentCell, actualPosition) = self.findParent(indexPath.row)
+        
+        if !isParentCell {
             cell = tableView.dequeueReusableCellWithIdentifier(childCellIdentifier, forIndexPath: indexPath)
-            cell.textLabel!.text = self.subItems[parent][indexPath.row - self.actualPositions[parent] - 1]
+            cell.textLabel!.text = self.dataSource[parent].childs[indexPath.row - actualPosition - 1]
             cell.backgroundColor = UIColor.greenColor()
         }
         else {
             cell = tableView.dequeueReusableCellWithIdentifier(parentCellIdentifier, forIndexPath: indexPath)
-            cell.textLabel!.text = self.topItems[parent]
+            cell.textLabel!.text = self.dataSource[parent].title
         }
         
         return cell

    /// The identifier for the parent cells.
    let parentCellIdentifier = "ParentCell"
    
    
    /// The identifier for the child cells.
    let childCellIdentifier = "ChildCell"
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

     
     - parameter index: The index of the cell to expand.
     */
    private func expandItemAtIndex(index : Int, parent: Int) {
        
        // the data of the childs for the specific parent cell.
        let currentSubItems = self.dataSource[parent].childs
        
        self.dataSource[parent].state = .Expanded
        
        // position to start to insert rows.
        var insertPos = index + 1
