Performance upgrade

Moved the terms loop inside the text node logic. Result is that the
terms are looped for each text node rather than traversing the entire
DOM tree for each term.