Matrix class fixes