Misc perf optimizations