some fixes for queries, imports optimization