added persistence and registering of listeners and handlers