build script, minor bug fixes