Major rework for inventory

Completely changed the way the inventory works and fixed all the
associated reports.