minor optimizations and add setObject() (from luis)
[BEAM-1637] Improve performance by using Apache commons-math performance optimisation: use Apache FastMath (patch from luis)