core: Moved to shared_ptr for handling distances, kernels and other pluggable stuff