Drastically reduce the number of queries

Drastically reduce the number of queries generated by PR #205