Fix queries for DB with table prefix; fixes #6