Fix matrix indexing for streaming and saving