Closes #3561548
This is a rebased version of !2 to make it easier to work on as that MR has the same branch name as 2.x which we need to rebase.