Unique words only, refactoring and optimizations.