Removed pointless code and fixed replacing inventories.