Cleanups and fixes, script works without grids.