Improved organization and refactored code