Added better support for query