Rename event-related functions. Perform minor cleanup.