Add a lot of helper functions. Read less oftem from the DOM. Try to move heuristcs outside of the grid class.