refactored external build scripts (untested).