speed optimizations (from a profiler)
Merge remote-tracking branch 'origin/master'