Added Grid class, which maintains the grid state