Tidy up of the grid generation code and reduction in the size of the resulting CSS.