various bug fixes to queries and methods.