Refactoring, adding templates and UI modules