Ensure $maxDistance is always the last part of the query (#179)