patched query plugin to handle awakenings intelligently