make sure event handlers get cleaned up during parsing
Merge pull request #1599 from evs-chris/gh-1598

Make sure event handlers get cleaned up during parsing