Better exception handling in ThemeMediator.
Minor cleanup.