Fix normalize algorithm

Not sure where previous one came from, surely it was a bad day
Assure unique array result