First part of the modernization changes from MR !711
MR !711 (closed) got out of sync with the master branch so there are too many conflicts for merging. Here I started to pick up commits with a plan to merge things in as soon as they are tested to be OK.
cc @adavis
Edited by Michal Kreps