significant template improvements