move templates in separate directory
avoid needless extra template
cleanup js code into reusable functions
show tags properly in Patterns/Group by info