Fix bugs with widget hierarchy deletion

Add beginLoaded support to widgets.