Fixed bug with indexing.