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