Added sum and matrix length helpers
Converted grid to 2d array