Added grid functionality, and minor refinements