Fix bugs

Fix bugs from Sonar