Improvements in queries and orm