Fixed bug with matrix serialization