Move task-query to its own module.

Closes #453.
Merge pull request #468 from 4teamwork/deif-task-query-rewrite

Move task-query to its own module.