Updated template parser, which required some changes