Implementation draft with shared_ptr. Avoiding copies.

Using C++11 features.
First draft with shared_ptr, maybe not the best since the ownership is not really divided, the API should be the only one owning the training objects...