client, npc refactoring