Mgalctc fixing sonar errors

Fixed all critical errors and some major/minor errors
This pull request also contains pull request #66.