Added some rudimentary event handling