Added support for user-defined distance functions in mlg.filter