Various small fixes to get external templates working better.