Bug fixes + build script fixes