Fix crashes in AI whenever a building is dismantled.