Fixed indexing problems