Might be good to have a separate PR for this since it modifies core. Also, it will simplify review of this PR which is probably going to take a while :)