Cleaned up implementation of CellularAutomaton