Udded templates for widget and ListOfWidget. Refactored many functions to follow the templates.