Completed formatting refactor for readability and maintainability.