some small performance improvements according to jsperf