Refactored code to reflect smarter inheritance structure