Added support for bad queries

Fixes #79