fix #28 (crash on unregister)