Rewrote Event management routines.