Replaced nested templates with looping control structures. Other parser cleanup as well.