Refactoring and sonar compliance

closes #8