Fixed bug in matrix reconstruction