Improved query discriminators. Should fix #16.