Major changes to the grid class and minor changes elsewhere.