Added event handling and a bit more