Updated compare function.

Todo: further pruning based on the stem.