fixed bugs in fmmatrix