Performance fixes for latest v13 RC

Merged by hand from master branch