Themes.php refactoring - part 2

just more refactoring for Themes.php
- moved some db queries to subs. 
- tried to use existing functions and remove code redundancy..

There's still some db related code in Themes.php.. I'll pick this in a different PR.