Refactored into smaller files