fixed bug that prevented event handlers from being removed properly