Refactored build scripts into functions.