minor speed optimizations