Optimize dom mutation handling; correct attribute fixup code to support nested templates.