Fixed minor bugs with indexing