adding better nesting and templating support - still a work in progress though