improved matrix deserialization for streams