Refactored ThemeManager to merge several functions to make the code a bit more readable.