Made reguritation of bad values more robust.