Fixing some perf issues