Optimizations in Stat Select code