Automatically select the right checkbox; fix event handling