Fix sync issues with async tasks