Fixes #106: inherited queries are broken

Here is a pull request containing @brianhelba patch