Less copying-around of point clouds

Two patches:

* the first uses `shared_ptr` in a smarter way than is done currently, to prevent lots of copies being made, as well as getting rid of some casts;
* the second refactors the registration code to get rid of some duplication.

Please see the commit messages for details.