Refactored build scripts to be more reusable.