Various changes, added @query handling