widgets: refactor data structures

Ref e7bbeb42dce8f69f3f18540d09b2a50e5256dc1b