Clamp indexes and lengths where appropriate in modern and underscore builds.