Fixed NPEs
Fixed build script