Rewrite of inventory click handling code