Adding TologQueryGenerator and refactoring.