Complete refactor with a generic superset of query syntax
Generic template
last version with companion objects and more concise code