Move task-query to its own module.

Closes #453.