Fix #739 "Event handler with incorrect `ev:observer` associates with parent"

- refactored
- log issues
- disable the handler when it makes sense
Fix #725 "StackOverflowError when inserting section template with repeat"