Refactored state, widgets and rendering into modules.