Don't you hate it when people leave the door open?
Fixes:
A better opening of gates and doors:
I have cleaned up the code around the gates and doors, it will help avoid the NPC just opening and closing a door over and over. This does not fix the teleporting thru a door as this is a result of Minecraft killing pathfinding through doors, so I believe citizens is teleporting the NPC through the doors.