Making sure events get handled in the right order