Fix some indexing problems introduced during cleanups