Refactoring classes and implementing best practices