improve buffer index mode and fix usages where there's overflow