overhaul events subsystem: API changes, ghashtable split for reg/mem events, signal handler in example and various bugfixes and improvements