adding better error checking in build script. mods for r9