Added template parsing and tag substitution code.