bug fix and build script fix