Introduce distance() and unify some API