 	
 	fileprivate var isDynamicLastCell: Bool = false
 	fileprivate var dynamicLastCellHeight: CGFloat?
+	fileprivate var previousRowFrame = CGRect()
 	
     /// Override in subclass, usually by connecting to an IBOutlet collection.
     var excludedCells: [UITableViewCell]? {

		// Use default height when last cell is not on the screen.
		guard tableView.indexPathsForVisibleRows?.contains(lastCellIndexPath) ?? false
			else { return }
		let previousRowFrame = tableView.rectForRow(at: IndexPath(row: lastCellIndexPath.row - 1, section: lastCellIndexPath.section))
		// Get height of empty spaces to fill
		let availableHeight = tableView.frame.size.height - previousRowFrame.maxY
		if let lastCell = tableView.cellForRow(at: lastCellIndexPath) {

			if isDynamicLastCell {
				if let dynamicLastCellHeight = self.dynamicLastCellHeight {
					height = dynamicLastCellHeight
					let currentPreviousRowFrame = tableView.rectForRow(at: IndexPath(row: indexPath.row - 1, section: indexPath.section))
					// Detect changes on tableView contents after dynamicLastCellHeight is set
					if currentPreviousRowFrame.maxY != previousRowFrame.maxY {
						refreshDynamicLastCellHeight()
					}
				}
			} else {
				previousRowFrame = tableView.rectForRow(at: IndexPath(row: indexPath.row - 1, section: indexPath.section))
				// Get height of empty spaces to fill
				let availableHeight = tableView.frame.size.height - previousRowFrame.maxY
				if availableHeight > lastCellIntrinsicHeight {
