Improve index/offset handling