Huge refactoring of deployment processing code