Improve build script

Now terminates on any error, rather than continuing on and causing
problems further down the road.