Various fixes

A couple of assorted fixes spotted by SonarQube. There are other issues reported but they are more subject to discussions.