globals
add {template} attributes, and fix a couple bugs