Template component improvements and small refactoring