Fixed an issue to do with out of bounds indexing with large sparse matrices.