Added maxDistance configuration option