Fix bugs for building scripts