Fixed a divide by zero bug in the grid