Greatly improved the query parser (still needs testing)