is separated in subtemplates for better modularity and testability and without any significant performance penalty.