Some changes to db queries to help speed things up
query juggling to improve speed