Improved template parsing.