Better abstraction of the theme code and small changes