fixed a few critical issues spotted by Sonar: https://analysis.apache.org/drilldown/violations/37401?priority=CRITICAL