Perf optimizations according to Emmanuel