Fix indexing issues