Fixed some critical Sonar issues