Code Refactor and enhancement

Theme related code refactors and enhancements.