Improove theme class and refactor some code