Fixed bug in grid calculation: did not include maximum value of specified range.