Same as #2933 but for master

I haven't run the tests locally. Hopefully nothing breaks with this few changes...
Cheers