formatting.
Some refactorings in the template rendering stuff to support some upcoming changes.