Various fixes for event generation.
Cleanup constants.
Cleanup exception handling.