Fixed event handlers to be more standards compliant