A few perf optimizations.