Refactored build script.