Make the inventory code more general (allowing unused slots).
Simplify code.