Could you make sure that when the script set any fields, they are all trimmed ? Let me tell you why. Assumming you use studio to categorize your movies, "Universal Studios " and "Universal Studios" will be treated as two different studios ! But they are the same !
Alternatively you could trim (left and right) when you display them in XMM, that should be a quick fix. And the sort or category will not have the white space issue as mentioned previously.
But in the long run, could you please make sure all the fields are trimmed while importing/exporting ? Thanks.