Fixed the error. There was a problem in the cellStartEnd kernel. It needs to be aware of empty cells. Otherwise the cell count kernel would give empty cells a value of 1.