Fix bugs with custom events