Various performance improvements.
Merge branch 'performance-improvements' into all-the-branches