Patches to correct templates syncing each boot.
Code cleanup.