item/inventory bug fix; refactoring NPC code