Refactor and improve code organization.