Readd distance functions to Stan

This resolves issue #283 .