Refactored code to improve its long-term maintenance.