separated query parsing from processing, a lot of fixes