Updating to use more range-based for loops, nullptr and auto. No functional changes.