Modernize hook handling

For reasons I can't say I understand, this fixes issues I was seeing with hangs after `G4` commands. The problem was clearly due to `on_play` events not being dispatched due to someone trashing the hooks table. While converting the hooks table to C++ containers fixes the issue, I'm afraid I have no explanation for why the original code was broken. That being said, I think this patch should stand on its own as worthwhile.