Pull request for smart code

Yay smart events!

The rest of the code ain't so smart but y'know