Fixed bug that caused events not to be emitted