autretract fix

I made these changes previously, but I can’t find the commit now. This
reapplies the changes to get auto retract working again.