Fixed bugs in build script