refactored inventory, fixed bug when items could overflow inventory max size