make NDims a const

for compiler optimizations
remove extra hacks, compiler will optimize this

no need to be this smart, remove extra code, compiler does
loop unrolling
removeindexGeZero check, UInt is always >= 0

and index is defined to use UInt, so the check is tautologically true