Trim input and fix uniq bug.