More robust build script