Fix a bug in matrix normalization