Extract functionality in to methods.

Introduced prune_identical_words and anagram? methods.