Fix critical error detected by sonar and added some minor docs