Fix before and after loaded events on widgets