Backported the fix from the tuner.