fix some bugs around painting/grids
cleanup and refactor