Second Refactoring

Refactored code to be more compliant.