Some perf optimizations