Fix widget-reusing code

Issue #1187