Fixed bugs after changes to ranges.