Fixed a couple of bugs with simple queries and where clauses (rarrr!).