Fix 2 major issues from sonar