Fixed simple bugs major which are warned on sonar.