Added mathadapt functionality and fixed projection for GPU.