Multiple enhancements and fixes

Details in individual commits.