Bug fix for unregister.