Fixed bug in normalization function.