Add new query name parsing, lots of other improvements