backporting stuff from inventory. [for review]

r?