bugfix in meltcormatrixtoflatmatrix function