fix bug with custom events and clean up debug output