Added debug messaging and proper event binding