Fix issue with event reentrancy

If an inner invoke removes a listener, the outer invoke now loops
over the stale listener length. To solve this we only clean up the
listener array when we are in the outermost invoke.
Merge pull request #457 from arv/event-reentrancy

Fix issue with event reentrancy