Refactoring to improve code quality metrics

Resolves #37