Sonar fixes

Fixes for sonar violations
Merge branch 'sonar' into 4.x
Merge branch '4.x'