Minor improvements to algorithms and ranges.