I struggled for a while to find a way to remove the WebPart entries orphaned by the deactivation and rectraction process in SharePoint, and found a neat way to this using the SPFeatureReceiver. After some testing I posted an article about it in the SharePoint section.