Fix errors on unregistering