Inventory connector bugfix.
Further optimizations of the code.