Misc ESQuery additions and bugfixes