ENH: Refactored code into widgets