Refactored script structure.