Fix some perf issues.