Not at all sure what's going on here... Should possibly be broken out into a separate function with some amount of documentation around it? Looks to be doing some form of normalization, but... Shrug?