Fix popular tags module returning duplicate rows, improve query in

general.