Modernization and fixes

Please see the commit messages for details. :)