Rewrote and cleaned up the build.sh script