Refactored the build script.