Updated to work with the event interface

Hi,
I have rewritten parts of the code to work with the new event interface.
The coding is still a mess and needs to be refactored.
Greetings :)