Fix callbacks to not make the popup prone to racing