Fixed a bug with events not working