Added support for $maxDistance (#179)