Fixing bugs on how the grid is calculated.