Various small perf tweaks