Switched to std::begin and end in most places