Change to use the internally stored max index rather than the bound.
Add sparse array format (untested).