Refactored sync between template and UI