Renamed some events and cleaned up code.