Fixed a bug which caused wrong initialization of matrices.