Minor changes in Custom, Dense and base distances.

Mainly move a few methods from headers to implementation files.