This patch was authored by SPJ, and extracted from "Improve the handling of used-once stuff" by Joachim.