Fixed writing to the grid, and properly resetting it.