Fixed build script permissions and a small bug in PV