Rewrote event system according to advice by virtuald, not exactly using generators, but same concept in passing an object to the function that indicates when the function should terminate.
Merge remote-tracking branch 'origin/master'