Fix issues found using CodePro audit tool

It's a lot, I know, but it should all still work in the same way...