bug fixes in widget unloading