grid_coords rewrite. Edge cases R hard.

this should squash the bug from rounding glitches.
add error message if grid coords length !== n

just in case.
update minified source