code review cleanup: fixed grammar and spelling errors; moved some string literals into member vars
replaced inner foreach loops with sorting by mysql and usort to find the facet containing the term with the highest count