various speed optimizations