adds range_max param

- reprojects x, y, z = range_max when no reading
- uses i=j=0 instead of i=j=1 (last 2 rows were discarded)
fixes minor warnings and cosmetics