Wunsafe-loop-optimizations fix

Some versions of gcc are apparently very paranoid about letting the
optimizer on loops they can't prove are finite; using < rather than <=
should fix that.
More Wconversion fixes

Mostly propagating "dim is now unsigned char" one step further, but a
lot of these are "local side/node indices are unsigned short" fixes I
missed on previous passes.