Added better support for reregistering apps.