Cleanups at the query engine part