Adapted to make it build on SL6 (where dist is always defined).