Improved classes handling with styles for templates