Factor out grid snapping into Grid class