AI server: Some cleanup. Also handle exceptions in the NPC thread as it seems to be responsible for a very random exception-induced crash that still hasn't reared its ugly head yet.