Refactor tag handling, focus more on significant terms

merge and refactor aggregation and query services

(from redmine: issue id 1185, created on 2018-09-07tgradl)