Adapted sotd code to treat all three heursitics easily.