Initial AI rework. More info to come.