Reworked event handlers to comply with the chrome extension security
restrictions.