Fix some queries, add engine support