Remove duplicates from arrays, replace null fields