Added function to unregister events