widget code reorganization