Fix most of the queries
Merge branch 'working'