Streamline a couple of the switches with some math.
Also add a PERL command to output "seeds" to check the grids.