fixed bugs relating to npc