Fixed race condition if patching finishes before the popup is shown