Added listener keyword for all events.
Cleaned up code to follow the guidelines of PEP08.