This is a follow-on to #10758 to help move 10758 along. The first fixes
a regression in master that was partially fixed in 10758, the second I'm
not sure if its a regression or not, but its clearly a bug that should
be fixed.
Backport of core PR10919
https://github.com/bitcoin/bitcoin/pull/10919/files
Note to reviewers:
The change in src/bitcoind.cpp is not backported as it should have
been removed in D2260.
Also some of the changes in src/init.cpp have already been (mistakenly
?) ported in D1910.