Added joint consistency check code and endpoint plot r2 code