Added code to template parser + few other fixes