Fix bug in QueryDirtyModels introduced in d322532.

Closes #183.