Improvements/fixes to app deregistration (but some still are pending).