Refactored templates processing