Preallocate arrays.
Merge remote-tracking branch 'origin/performance_improvements' into next