Several speed optimizations