Some speed optimizations