Added a fix for invalid cell placements.