Fixed bug with unregister when no listener was provided for register