Continues #5697
I'm very open to squash anything, separate foreach into a different PR or some other suggestion that it's mostly include-only.
Less to catch these days, that's a good sign Related branch: https://github.com/jtimon/bitcoin/commits/long-globals