Merge further performance improvements from @jakebolewski