OP-1309 some CPU and memory optimizations to get it to run on CC
OP-1309 turned boundf() static inline as requested