Fixed bug with unregister