Cleaning up grid generation code.