Better parsing of queries