Working copy. Cpose3d not fully tested yet.