improved event handling. There are still some memory leaks.