Issue101

Fixes #101. I refactored a bit of inventory while I was at it, to make it so this bug should be less likely to come back.

Probably best to just look at the files that changed rather than the diff- it's not very clear for this changeset.