lots of refactoring to achieve some kind of theme support