rewrote XGP implementation, increasing performance