Patches to make rebuilding work with new template system.