Fixed dodgy issues as per sonar report.