calculating rows now takes modulus into account
cleaned up grid.js
cleaned up grid.js