Improve performance of some queries